Top Description Inners Fields Constructors Methods
org.glassfish.pfl.test

public Class JUnitReportHelper

extends Object
Class Inheritance
Imports
java.io.File, .FileOutputStream, .OutputStream, org.glassfish.pfl.basic.contain.Pair

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 and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private String
private JUnitReportHelper.Counts
private JUnitReportWriter.TestDescription
private final boolean
private String
private boolean
private JUnitReportWriter

Constructor Summary

AccessConstructor and Description
public
JUnitReportHelper(String
The class name of the class for this test
cname
)

Prepare to generate a JUnitReport in the file named ${junit.report.dir}/${name}.xml.

Method Summary

Modifier and TypeMethod and Description
private void
public JUnitReportHelper.Counts
done()

Testing is complete.

public void
fail(String msg)

Report that the current test failed with an error message.

public void
fail(Throwable thr)

Report that the current test failed with the given exception as cause.

public void
fail(String msg, long duration)

Report that the current test failed with an error message.

public void
fail(Throwable thr, long duration)

Report that the current test failed with the given exception as cause.

private void
msg(String str)

public void
pass()

Report that the current test passed.

public void
pass(long duration)

Report that the current test passed.

public void
start(String
The name of the test case
name
)

Start executing a test case with the given name.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

classNameback to summary
private String className
countsback to summary
private JUnitReportHelper.Counts counts
currentback to summary
private JUnitReportWriter.TestDescription current
DEBUGback to summary
private final boolean DEBUG
fileNameback to summary
private String fileName
testCompleteback to summary
private boolean testComplete
writerback to summary
private JUnitReportWriter writer

Constructor Detail

JUnitReportHelperback to summary
public JUnitReportHelper(String cname)

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:String

The class name of the class for this test

Method Detail

checkCurrentback to summary
private void checkCurrent()
doneback to summary
public JUnitReportHelper.Counts 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.

failback to summary
public void fail(String msg)

Report that the current test failed with an error message.

failback to summary
public void fail(Throwable thr)

Report that the current test failed with the given exception as cause.

failback to summary
public void fail(String msg, long duration)

Report that the current test failed with an error message.

failback to summary
public void fail(Throwable thr, long duration)

Report that the current test failed with the given exception as cause.

msgback to summary
private void msg(String str)
passback to summary
public void pass()

Report that the current test passed.

passback to summary
public void pass(long duration)

Report that the current test passed.

startback to summary
public void start(String name)

Start executing a test case with the given name. All names MUST be unique for an instance of JUnitReportHelper.

Parameters
name:String

The name of the test case

org.glassfish.pfl.test back to summary

public Class JUnitReportHelper.Counts

extends Pair<Integer, Integer>
Class Inheritance

Field Summary

Inherited from org.glassfish.pfl.basic.contain.Pair:
_first_second

Constructor Summary

AccessConstructor and Description
pack-priv
Counts(int numPass, int numFail)

Method Summary

Modifier and TypeMethod and Description
public int
public int
Inherited from org.glassfish.pfl.basic.contain.Pair:
equalsfirsthashCodesecondtoString

Constructor Detail

Countsback to summary
pack-priv Counts(int numPass, int numFail)

Method Detail

numFailback to summary
public int numFail()
numPassback to summary
public int numPass()