The test runner is invoked in the same way as the standard textui test runner implementation: java junit.textui.SelectiveTestRunner<testsuite>
However it supports the following additional options:
-names:
Lists each of the test cases encountered as a test number and test name, which can be used to select the test using the options described below. The test cases are not run.
java junit.textui.SelectiveTestRunner -names subject.tests.ATestSuite
-sID<id1,id2,id4-id7,...,idN>:
Select tests by number (ID). Accepts a comma-delimited list of test numbers identifying tests to be run. Ranges are allowed.
java junit.textui.SelectiveTestRunner -sID 5 subject.tests.ATestSuite >& t5
-sName <name1,name2,...,nameN>
Select tests by name. Accepts a comma-delimited list of test names.
java junit.textui.SelectiveTestRunner -sName subject.tests.testMethod subject.tests.ATestSuite
-o<dir>:
Instructs the test runner to save outputs of test cases to directory 'dir'. The files will be named in the form tX where X is the test number. (For example, running tests 3-5 would produce the files 't3', 't4', and 't5').
java junit.textui.SelectiveTestRunner -sID 3,5,9-12 -o outputs subject.tests.ATestSuite
-d<dir>:
Instructs the test runner to difference the output of each test case with the output from a previous run of that test case, found in directory 'dir'. A message is printed for outputs that differ. Trace files will also be diffed when executing a traced run.
java junit.textui.SelectiveTestRunner -sID 3,5,9-12 -o outputs -d previous subject.tests.ATestSuite
-p:
Instructs the test runner to prioritize the tests. The tests will be executed in a specified order as inserted in command line.
java junit.textui.SelectiveTestRunner subject.tests.ATestSuite -p -sID 3,1,2
-univ<name>:
Generate a universe file that can be used to run the same set of tests one at a time.
java junit.textui.SelectiveTestRunner subject.tests.ATestSuite -sID 1-3 -univ UniverseFile.txt
-t <options>
Instructs the test runner to collect trace information for each test case in trace files. The subject classes must be instrumented using the '-junit' option to sofya.ed.cfInstrumentor. The <options> portion is a comma delimited list of option name/value pairs in the form 'name=value'. The following options are valid:
java junit.textui.SelectiveTestRunner -sID 5 -t type=B subject.tests.ATestSuite >& t5
javajunit.textui.SelectiveTestRunner-sID1-5-ttype=EXC,at=true subject.tests.ATestSuite
Known Issues
Tracing the recursive case (running JUnit tests for instrumented JUnit itself) will not give correct results. The test selection classes subclass the instrumented classes, causing trace data to be recorded which represents the execution of the invoking environment as well as the test cases themselves.
Creation of traces and saving of outputs will NOT work with test suites built using the junit.extensions.ActiveTestSuite class. The test runner depends on the sequential execution of the test cases, an assumption which is violated by the ActiveTestSuite class.
Author: Alex Kinneer © 2006 University of Nebraska - Lincoln.
Page last updated by Wayne Motycka: 08/27/2018