Package org.glassfish.pfl.test
Class JUnitReportHelper
java.lang.Object
org.glassfish.pfl.test.JUnitReportHelper
Helper class for generating reports for tests that do not adapt well to
Testng/JUnit. For example, several tests re-run the same test method and
class many times with different parameters. JUnit does not support this at
all. Testng does, but it is too much work to adapt these tests. Instead,
we can just bracket test case execution with start/(pass|fail) calls.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate String
private JUnitReportHelper.Counts
private final boolean
private String
private boolean
private JUnitReportWriter
-
Constructor Summary
ConstructorsConstructorDescriptionJUnitReportHelper
(String cname) Prepare to generate a JUnitReport in the file named ${junit.report.dir}/${name}.xml. -
Method Summary
Modifier and TypeMethodDescriptionprivate void
done()
Testing is complete.void
Report that the current test failed with an error message.void
Report that the current test failed with an error message.void
Report that the current test failed with the given exception as cause.void
Report that the current test failed with the given exception as cause.private void
void
pass()
Report that the current test passed.void
pass
(long duration) Report that the current test passed.void
Start executing a test case with the given name.
-
Field Details
-
DEBUG
private final boolean DEBUG -
writer
-
className
-
fileName
-
current
-
testComplete
private boolean testComplete -
counts
-
-
Constructor Details
-
JUnitReportHelper
Prepare to generate a JUnitReport in the file named ${junit.report.dir}/${name}.xml. junit.report.dir is obtained from the environment variable which is passed to all CTF controllers.- Parameters:
cname
- The class name of the class for this test
-
-
Method Details
-
msg
-
checkCurrent
private void checkCurrent() -
start
Start executing a test case with the given name. All names MUST be unique for an instance of JUnitReportHelper.- Parameters:
name
- The name of the test case
-
pass
public void pass()Report that the current test passed. -
fail
Report that the current test failed with an error message. -
fail
Report that the current test failed with the given exception as cause. -
pass
public void pass(long duration) Report that the current test passed. -
fail
Report that the current test failed with an error message. -
fail
Report that the current test failed with the given exception as cause. -
done
Testing is complete. Calls to start, pass, or fail after this call will result in an IllegalStateException. This method may be called multiple times, but only the first call will write a report.
-