Here is the first white box test, in fact, in order to further specify some of the theories mentioned before, explain how to do and why do it. These examples are mostly I took out after I saw the relevant information, and then I added some of my insights in the process of learning.
Starting from a typical class
The first typical Java program generally includes main () of "Hello World". In Listing 1, I created an instance of a HelloWorld object and called a SayHello () method, which prints this habit.
Listing 1. My first Java application "Hello World"
/ *
* HelloWorld.java
* My First Java Program
* /
Class helloworld {
/ **
* Print "Hello World"
* /
Void syhello () {
System.out.println ("Hello World");
}
/ **
* Test
* /
Public static void main (String [] args) {
HelloWorld World = New HelloWorld ();
World.SAYHELLO ();
}
}
The main () method is my test. Oh! I am included in a module in a module. Bless Java! But as the program is getting bigger, this development method will soon start show defects:
confusion
The larger the class interface, the greater the main (). The class may be very large because of the normal test.
Code expansion
Since the test is added, the product code is larger than the need. But I don't want to pay the test, but I only want to deliver the product.
Test is unreliable
Since main () is part of the code, Main () enjoys access to other developers from private members and methods that cannot be accessed by class interfaces. For this reason, this test method is easily error.
It's hard to test
To perform automatic test, I still have to create another program to pass the parameters to main ().
This method corresponds to "call the main method in the class, and write the test case that needs to be run in the main method body, and then compiles the class execution." Its biggest a bit is what you get, but in addition to the defects above, we don't think about it else to have some other defects:
It is not conducive to post-test code to maintain a re-delivery process that is not conducive to test code, must be proposed one by one.
From this, we introduce the JUnit test framework. If you want to know more about this knowledge (including how we should consider improvement, how to implement improvements, etc.) Please refer to the article of IBM Developer website.
Incremental development using Ant and Junit [
http://www-900.ibm.com/developerWorks/cn/java/j-ant/index.shtml. In addition, in order to reduce the reading burden of the test personnel. Here I will continue to reference some of the original text and some of my own elaboration to our journey.
People who have used Rational TestManage may know that first create a test suite when using it to manage test scripts, it can be said that it is used to organize a container for testing the script, which is used to include a separate test script, or Contains other test kits, even contains test scenes (Scenario, such as all scripts that initialize the environment or on site, so that each test case can be run in the same environment). The set of Suite in Rational TestManage can be flexible, basically able to meet various business logic, here that actually I think the automated test suite can be understood by this concept, using different languages The kit is only different in grammar, and they can be abstracted as described above. Each test script can be seen as a test case, or multiple test scripts can also be combined into a test case, which is the need for readers in practical use in practical use. Some of these ideas, I think as a black box tester should have a certain look at the test script generated under the JUnit test framework. Say that some more important things related to test cases, JUnit official website also offers some gadgets, such as jub.zip, junitperf-1.9.1.zip, JUnitscenario-0.1.zip equivalence tools can be used to manage test cases, generate test cases, perform unit performance testing, and more. If you are interested, you can further study and use, and they are also open source.
(This article is not very complete, will be supplemented in future articles)