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 classJsonReport.OutputMethod
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringjsonpMethodprivate JsonWriterjsonWriterprivate JUnit4junit4private JsonReport.OutputMethodmethodHow should the report be written?private booleanoutputStreamsprivate java.lang.StringprojectNameprivate java.util.Map<java.lang.Integer,ForkedJvmInfo>slavesprivate java.io.FiletargetFileprivate java.io.OutputStreamWriterwriter
-
Constructor Summary
Constructors Constructor Description JsonReport()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcopyScaffolding(java.io.File targetFile)Copy HTML/JS/CSS scaffolding to a targetFile's directory.private java.lang.StringgetProjectName()Return the project name or the default project name.voidonQuit(AggregatedQuitEvent e)All tests completed.voidonSuiteResult(AggregatedSuiteResultEvent e)Emit information about a single suite and all of its tests.private java.lang.StringremoveExtension(java.lang.String name)voidsetFile(java.io.File file)Output file for the report file.voidsetJsonpMethod(java.lang.String method)Sets wrapper method name for JSONP.voidsetOuter(JUnit4 junit4)Link to the container.voidsetOutputStreams(boolean outputStreams)Include output streams? Mind that with large outputs the report may OOM.voidsetProjectName(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:AggregatedEventListenerLink to the container. Listener can throwBuildExceptionif parameter validation doesn't succeed, for example.- Specified by:
setOuterin 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.IOExceptionCopy HTML/JS/CSS scaffolding to a targetFile's directory.- Throws:
java.io.IOException
-
-