Class JsonReport
- java.lang.Object
-
- com.carrotsearch.ant.tasks.junit4.listeners.json.JsonReport
-
- All Implemented Interfaces:
AggregatedEventListener
public class JsonReport extends java.lang.Object implements AggregatedEventListener
A report listener that produces a single JSON file for all suites and tests.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
JsonReport.OutputMethod
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
jsonpMethod
private JsonWriter
jsonWriter
private JUnit4
junit4
private JsonReport.OutputMethod
method
How should the report be written?private boolean
outputStreams
private java.lang.String
projectName
private java.util.Map<java.lang.Integer,ForkedJvmInfo>
slaves
private java.io.File
targetFile
private java.io.OutputStreamWriter
writer
-
Constructor Summary
Constructors Constructor Description JsonReport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
copyScaffolding(java.io.File targetFile)
Copy HTML/JS/CSS scaffolding to a targetFile's directory.private java.lang.String
getProjectName()
Return the project name or the default project name.void
onQuit(AggregatedQuitEvent e)
All tests completed.void
onSuiteResult(AggregatedSuiteResultEvent e)
Emit information about a single suite and all of its tests.private java.lang.String
removeExtension(java.lang.String name)
void
setFile(java.io.File file)
Output file for the report file.void
setJsonpMethod(java.lang.String method)
Sets wrapper method name for JSONP.void
setOuter(JUnit4 junit4)
Link to the container.void
setOutputStreams(boolean outputStreams)
Include output streams? Mind that with large outputs the report may OOM.void
setProjectName(java.lang.String projectName)
Set project name for the output model.
-
-
-
Field Detail
-
junit4
private JUnit4 junit4
-
targetFile
private java.io.File targetFile
-
jsonpMethod
private java.lang.String jsonpMethod
-
jsonWriter
private JsonWriter jsonWriter
-
projectName
private java.lang.String projectName
-
slaves
private java.util.Map<java.lang.Integer,ForkedJvmInfo> slaves
-
writer
private java.io.OutputStreamWriter writer
-
method
private JsonReport.OutputMethod method
How should the report be written?
-
outputStreams
private boolean outputStreams
- See Also:
setOutputStreams(boolean)
-
-
Method Detail
-
setFile
public void setFile(java.io.File file)
Output file for the report file. The name of the output file will also trigger how the report is written. If the name of the output file ends with ".htm(l)?" then the output file is a HTML file and CSS/JS scaffolding is also written to visualize the JSON model. If the name of the file ends with ".json(p)?" a JSON file is written.
-
setJsonpMethod
public void setJsonpMethod(java.lang.String method)
Sets wrapper method name for JSONP. If set to non-empty value, will change the output format to JSONP. The name of the JSONP function for the HTML wrapper must be "testData".- See Also:
- "http://en.wikipedia.org/wiki/JSONP"
-
setProjectName
public void setProjectName(java.lang.String projectName)
Set project name for the output model.
-
setOutputStreams
public void setOutputStreams(boolean outputStreams)
Include output streams? Mind that with large outputs the report may OOM.
-
setOuter
public void setOuter(JUnit4 junit4)
Description copied from interface:AggregatedEventListener
Link to the container. Listener can throwBuildException
if parameter validation doesn't succeed, for example.- Specified by:
setOuter
in interfaceAggregatedEventListener
-
removeExtension
private java.lang.String removeExtension(java.lang.String name)
-
getProjectName
private java.lang.String getProjectName()
Return the project name or the default project name.
-
onSuiteResult
public void onSuiteResult(AggregatedSuiteResultEvent e)
Emit information about a single suite and all of its tests.
-
onQuit
public void onQuit(AggregatedQuitEvent e)
All tests completed.
-
copyScaffolding
private void copyScaffolding(java.io.File targetFile) throws java.io.IOException
Copy HTML/JS/CSS scaffolding to a targetFile's directory.- Throws:
java.io.IOException
-
-