
Static Public Member Functions | |
| static void | run (Class testClass) throws FileNotFoundException |
| static void | main (String[] args) |
Static Private Member Functions | |
| static void | redirectSysOutputStreams () throws FileNotFoundException |
| static void | restoreSysOutputStreams () |
| static void | closeFiles () |
| static void | run (Test suite) |
| static void | traceOutput (boolean isFailure) |
Static Private Attributes | |
| static PrintStream | s_oldSysOut = System.out |
| static PrintStream | s_oldSysErr = System.err |
| static FileOutputStream | s_fileoutstream |
| static FileOutputStream | s_fileerrstream |
| static FileOutputStream | s_fileresultstream |
| static String | outFilename |
| static String | errFilename |
| static String | resFilename |
Replacement for junit.textui.TestRunner that helps avoid some issues with using JUnit embedded in ALMA TAT scripts.
Note that the intent is not to get rid of the output-based testing that TAT offers, but to complement it with result-based testing as JUnit proposes it, and to make the latter easier in a TAT environment. Both approaches have their merit, so chose one depending on what you want to test.
Internally calls TestRunner#doRun(Test), controlling the ResultPrinter output as well as System.out and System.err.
Fixes the following issues
TestRunner produces too much output, which forces test developers to provide TAT with reference output files of all successful JUnit test runs, which seems absurd given that JUnit does all error checks already itself.TATJUnitRunner produces no output for successful tests, which means it suppresses TestRunners output System.out System.err TestRunner and TATJUnitRunner return an exit code 0 to indicate a successful run. TestRunner reports this in the execution summary, without giving any details on the problem, e.g. the assertion that caused the failure.TATJUnitRunner in this case becomes rather verbose and dumps on System.err TestRunner output using a ResultPrinter. System.out during test execution System.err during test execution TestRunner and TATJUnitRunner return an exit code 1 for a failure and 2 for an error. For either failure or success, the following line is printed as the first line to stdout, so that TAT or other tools can analyze how many tests have run, and how many succeeded:
TEST_RUNNER_REPORT success/total: int/int
where int is replaced by the respective integer number.
| static void alma::acs::testsupport::tat::TATJUnitRunner::closeFiles | ( | ) | [inline, static, private] |
References s_fileerrstream, s_fileoutstream, and s_fileresultstream.
Referenced by run().
| static void alma::acs::testsupport::tat::TATJUnitRunner::main | ( | String[] | args | ) | [inline, static] |
References errFilename, outFilename, resFilename, and run().
| static void alma::acs::testsupport::tat::TATJUnitRunner::redirectSysOutputStreams | ( | ) | throws FileNotFoundException [inline, static, private] |
References errFilename, outFilename, s_fileerrstream, s_fileoutstream, s_oldSysErr, and s_oldSysOut.
Referenced by run().
| static void alma::acs::testsupport::tat::TATJUnitRunner::restoreSysOutputStreams | ( | ) | [inline, static, private] |
References s_oldSysErr, and s_oldSysOut.
Referenced by run().
| static void alma::acs::testsupport::tat::TATJUnitRunner::run | ( | Test | suite | ) | [inline, static, private] |
Note that if this method should become public in the future (and thus can be called directly, rather than from run(Class), the handling of the output streams and the like must be shared properly between the two run methods.
| suite |
References closeFiles(), errFilename, outFilename, resFilename, restoreSysOutputStreams(), s_fileresultstream, and traceOutput().
| static void alma::acs::testsupport::tat::TATJUnitRunner::run | ( | Class | testClass | ) | throws FileNotFoundException [inline, static] |
Runs a suite extracted from a TestCase subclass.
Redirects System.out and System.err so that successful test runs will not produce any output, while in case of failure/error they get dumped to System.err.
References redirectSysOutputStreams(), resFilename, and s_fileresultstream.
Referenced by main().
| static void alma::acs::testsupport::tat::TATJUnitRunner::traceOutput | ( | boolean | isFailure | ) | [inline, static, private] |
References errFilename, outFilename, and resFilename.
Referenced by run().
String alma::acs::testsupport::tat::TATJUnitRunner::errFilename [static, private] |
Referenced by main(), redirectSysOutputStreams(), run(), and traceOutput().
String alma::acs::testsupport::tat::TATJUnitRunner::outFilename [static, private] |
Referenced by main(), redirectSysOutputStreams(), run(), and traceOutput().
String alma::acs::testsupport::tat::TATJUnitRunner::resFilename [static, private] |
Referenced by main(), run(), and traceOutput().
FileOutputStream alma::acs::testsupport::tat::TATJUnitRunner::s_fileerrstream [static, private] |
Referenced by closeFiles(), and redirectSysOutputStreams().
FileOutputStream alma::acs::testsupport::tat::TATJUnitRunner::s_fileoutstream [static, private] |
Referenced by closeFiles(), and redirectSysOutputStreams().
FileOutputStream alma::acs::testsupport::tat::TATJUnitRunner::s_fileresultstream [static, private] |
Referenced by closeFiles(), and run().
PrintStream alma::acs::testsupport::tat::TATJUnitRunner::s_oldSysErr = System.err [static, private] |
Referenced by redirectSysOutputStreams(), and restoreSysOutputStreams().
PrintStream alma::acs::testsupport::tat::TATJUnitRunner::s_oldSysOut = System.out [static, private] |
Referenced by redirectSysOutputStreams(), and restoreSysOutputStreams().
1.6.2