Pursuit of code quality: repeatable test system
Class: Junior
Andrew Glover (aglover@stelligent.com), the president of Stelligent Incorporated
November 2, 2006
Added to the test servlet containers Web applications, the preparation of logical repeatable testing is particularly necessary skills. Andrew Glover in the improvement of the quality of this sequel to the code, he introduced Cargo, which is a common way to automate the management of containers open source framework With this framework, you can be prepared in line with the logic of duplication of system testing.
In essence, like TestNG JUnit and the same testing framework to facilitate the reproducibility of test creation. As a result of these framework of a simple Boolean logic (in the form of methods to assert) the reliability, which makes unmanned test run for the intervention possible. In fact, automated testing framework is one of the main advantages - I can prepare for a specific assertion of a complex test, and if these acts have changed, the report will be a framework everyone can understand mistakes.
Mature framework of the test repeatability framework will bring the advantages of this are obvious. But the logic of repeatability depends on you. For example, consider creating Web applications used to validate the test can be repeated, extended some JUnit framework (such as JWebUnit and HttpUnit) in assisting the automated Web testing is very useful. However, the test can be repeated plumbing is the task of development, and the deployment of Web applications resources difficult.
JWebUnit actual testing process relatively simple structure, as shown in a list:
discussion forums, access to the code prepared by the method of testing the framework of the preparation of high-quality code and help.
Examples from this small parts (ie, widget-id) can be judged from the certification, can safely make the assumption that this application of the database constraints are likely to prevent the creation of an already existing and additional small parts. Due to the lack of a running another test to delete this test case before the goal of the process of small parts, if continuous operation twice this test case is very likely to fail.
Fortunately, as discussed in the previous article, as a help database - Dependence (database-dependent) mechanism repeatability test case - DbUnit.
list in a test case to use DbUnit is very simple. DbUnit need only insert some database data and a corresponding database connection, as shown in the list:
list a list of 2 and defined in the test case known as system testing. Because the system installed integrity of the test run applications, such as Web applications, which usually contain a servlet containers and an associated database. The purpose of these tests is to verify those designed for end-to-end operation of external interfaces (such as a Web application in the Web page).
inventory list and 2 in a display of logic in the pre-operational testing requires the following steps:
- The creation of a war document, the document contains all the relevant Web content, such as JSP documents, servlet, third-party jar files, images, etc..
- Document this war deployment to the target Web container. (If the container has not been activated, the activation of the containers.)
- Launch any relevant databases. (If you need to update the database model, in the pre-update.)
Now, for a negligible small test to do a lot of supplementary work! If it is shown that this process is time-consuming, so you think this test will be running a long interval? To test system in the face of logic can repeat (in a continuous integration environment) of this demand, this step is indeed daunting list.
![]()
![]()
![]()
list in the 4 and 6 list the code together, with two Cargo task Packaging a test objectives: one used to start Tomcat, for another stop Tomcat. Antcall call in the task list in the definition of 8 _run-called system-tests goal.
list of two test cases defined in this directory is located.
7 in the list, complete distribution of the Ant build files, which will test and Cargo System deployment package together. 7 in the list of the code to ensure that the list of 8 test / directory system under test all systems are logically can be repetitive. May at any time on any machine running on these systems testing, continuous integration environment Jia You. The test containers makes no assumptions - do not assume the position, or even whether their operation do not assume! (Of course, these tests are still done a hypothetical, I did not emphasize that the potential good and the configuration database in the operation of the. But that is another topic to be discussed.)
![]()
![]()
![]()
original English text.
Access to products and technologies
- Download Cargo: to re-test the Web easier.
- Download JUnit: View JUnit 4 new features.
- Download TestNG: Another powerful testing framework.
Discuss
- Participate in the discussion forum.
Stelligent Incorporated, the company used to test the development of effective strategies and to our team in the early regular monitoring of code quality continued integration technology to help enterprises solve software quality issues. He is Java Testing Patterns (Wiley, September 2004) co-author of the book.
Tags: java system, System






