Learning experience--analysis of testing framework

Source: Internet
Author: User

I press: In this semester of software Testing course learning, I gradually came into contact with the relevant knowledge of software testing, realized from the more concerned about the software writing and implementation of the front-end content to the gradual understanding of software testing and other projects in the later stages of the cross-

The more with the change. In the field of software testing, we often hear the term test framework, what is the test framework? What role does it play in software testing? I will be a shallow learning experience, here for the big

Home to do a simple analysis and communication.

Text: Let's take a look at the definition of the term "framework" given by Baidu Encyclopedia: "Framework" is a basic conceptual structure used to solve or deal with complex problems. "Then if we will frame

What general concepts can be given when this concept is introduced into the field of software? After comparing various interpretations, the author thinks that the following explanations are more general and comprehensive: the framework is a reusable design of the whole or part of the system,

It is represented as a set of abstract components and the method of interaction among the component instances.

For the above definition, I think the key words in two words: "Reusable" and "interactive." If you want to understand the meaning of these two words in depth, I think, here we should delve into the following why we need in software testing

The concept of testing framework is introduced in the field, and with the increasing of software project, the position of software testing in software development becomes more and more important. If a software project does not have a good test flow, as the system grows, no matter the project

Managers or software developers will lose confidence in the project's prospects and even diverge from the project's goals, as there has been no effective control over the program code and system design for a long time, and many issues have been temporarily masked

Cover or evolve into other problems. The longer the software development cycle, the more versions of the problem evolve, and the result is a "cut-and-go". The advantages of the test framework are: increased development speed, improved measurement

Test the execution efficiency of code, improve the quality of software code, and introduce the concept of refactoring, so that the code is cleaner and more flexible; to improve the reliability of the system, as a method of regression testing, it supports "re-testing" after repair to ensure

The correctness of the code. Common test framework classifications include automated test frameworks and unit test frameworks. Depending on the development platform you are using, you can also use different test frameworks to expand your testing.

On the "reusable", I think we can simply understand the software testing framework as: The test framework is not a complete system out of the box, but a semi-finished, test engineers can combine their own test object test

Requirements and translate them into test cases that are available to you. To make a simple analogy, the test framework is like a set up stage, and the test engineer (dancer) on this open, standardized set of stage

Jump out of the dance you want to jump. Software testing framework extracts the common part of software testing system and the system structure, which is based on software testing, as long as the adjustment of some content can meet their own needs, can

To effectively reduce development costs and shorten development time. This is what the software testing Framework's "reusable" properties mean.

As for "interaction," we know that the test framework that is commonly used now has an automated test framework and a unit test framework, and automated testing is to replace more manual tests, while unit tests are the whole test

The most basic part of the process, which requires programmers to identify problems as early as possible and give control, this is one. Also, if there is a problem with the integration test, they can help diagnose. This is a way to build a software development process

A solid foundation for efficient event response mechanisms. If the build interaction cannot be achieved in the test framework, unit testing becomes difficult and difficult to implement, thus the significance of the word "interaction" in the test framework.

The author, in combination with the knowledge I have learned, gives an example of the unit testing framework here: JUnit, specific examples of other types of testing frameworks, interested readers can refer to the relevant papers, into the study.

JUnit is the most well-known unit testing tool in the Java community; CppUnit is an open source project based on LGPL, originally ported from JUnit and is a very good open-source testing framework.

When using JUnit, you write test cases primarily by inheriting the TestCase category, and you use the testxxx () name to compose unit tests.

Three things you really need to write a test with JUnit:

1. An import statement introduces classes under all junit.framework.*.

2. A extends statement allows your class to inherit from the TestCase.

3. A constructor that calls super (string).

  

Function Class Mathtool:

PackageCOM.ZJ.C01; Public classMathtool { Public Static intgcd intNUM1, intNUM2) { intR = 0; while(num2! = 0)                              {r = num1% Num2;                              NUM1 = num2;                          num2 = R; } returnNUM1; }} Test Class Mathtooltest: PackageCOM.ZJ.C01; ImportJunit.framework.TestCase; Public classMathtooltest extendsTestCase { PublicMathtooltest (String name) { Super(name); } Public voidTESTGCD () { assertequals(5, Mathtool. GCD(10, 5)); }} Supplement: various assertions by JUnit

JUnit provides helper functions to help you determine if a function being tested works correctly. In general, we refer to all these functions collectively as assertions. Assertions are the most basic component of unit testing.

1. Assertequals ([String message], expected,actual)

Compares two basic types or objects for equality (expected and actual are primitive type values (primitive value) or must have a equal method for the implementation comparison);

2.assertFalse ([String message],boolean condition)

Evaluates the Boolean value to see if it is "true";

3.assertTrue ([String message],boolean condition)

Evaluates the Boolean value to see if it is "false";

4.assertNull ([String message],java.lang.object Object)

Checks whether the object is "empty";

5.assertNotNull ([String message],java.lang.object Object)

Checks whether the object is not "empty";

6.assertSame ([String message],expected,actual)

Check whether two objects are the same instance;

7.assertNotSame ([String message],expected,actual)

Checks whether two objects are not the same instance;

8. Fail (String message)

Causes the test to fail immediately, where the message parameter is made optional. This assertion is often used to mark a branch that should not be reached (for example, after an expected exception)

Related knowledge:

White box and black box frame

Frame can be divided into white box (white-box) and black Box (Black-box) two kinds of frame. The detailed contents of the relevant concepts, interested readers can learn and learn in-depth.

Learning experience--analysis of testing framework

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.