Download T2 : Automated Testing Tool for Java User Manual
Transcript
6 CHAPTER 1. QUICK START This will unleash T2 to test the class Point from the java.awt package. A couple of things to note here: 1. You need to supply a fully qualified name of the target class. 2. The must turn on the -ea flag! This enables assertion checking. Else T2 will skip off your specifications. 3. Include the path to your TT jar in the -cp (class path) argument. If T2 finds an error, it will report it. You probably won’t find any error in the class Point. To see how T2 reports an error let’s try to run it on one of the example classes included in T2 jar. Try this: java -ea -cp TT.jar Sequenic.T2.Main Examples.SimpleSortedList This will test the class SimpleSortedList from the package Examples. As the name suggest, the class is a simple implementation of a sorted list. It contains an error, and see how T2 finds it. The code of this class is in Figure 3.1. Options T2 allows you to specify options to influence its behavior. Options are listed after the name of the target class (the class to test). By default T2 will stop after trying 500 steps, or after finding the first violation. Using the option --violmax we can make T2 to search for more violations. For example to make it find up to 3 violations in SimpleSortedList we do: java -ea -cp TT.jar Sequenic.T2.Main Examples.SimpleSortedList --violmax=3 There is no guarantee however that T2 will find three different errors; its strategy to generate tests is basically random-based. Anyway, we have seen an example of how to pass an option to T2. The main tool (Sequenic.T2.Main) it self is actually a bundle of several tools. It contains at least T2’s random-based test generator tool and a replay (regression) tool. Each tool plugged into Main can be called by passing the right selector, with the exception the the test generator tool, which is the default tool. It requires no selector to pass (which is why we don’t see it in the examples above). Calling Main with no argument: java -cp TT.jar Sequenic.T2.Main will show the general use of Main, and available tool selector. This: java -cp TT.jar java -cp TT.jar Sequenic.T2.Main -E --help Sequenic.T2.Main -R --help will show the general use of the test generator tool respectively the replay tool, and short descriptions of available options. T2 has lots of options. See Chapter 8. Replay tool The typical work cycle when using T2 is: 1. Write your class. Code in your specifications as needed. 2. Run a test with T2. Ask T2 to save test sequences, including violating ones. 3. Repair bugs.