package com.yahoo.dtf.actions.results;
import java.net.URI;
import com.yahoo.dtf.actions.Action;
import com.yahoo.dtf.exception.ActionException;
import com.yahoo.dtf.exception.DTFException;
import com.yahoo.dtf.exception.ParseException;
import com.yahoo.dtf.results.ResultsBase;
import com.yahoo.dtf.results.ResultsFactory;
/**
* @dtf.tag result
*
* @dtf.since 1.0
* @dtf.author Rodney Gomes
*
* @dtf.tag.desc <p>
* Specifies location to record testcase results that are
* generated by the execution of testsuite and testscript tags.
* </p>
* <p>
* Recording test results into other format is useful when you want
* to generate different reports of the same results. Also you'll
* find its easier to keep track of the history of running tests
* using this mechanism.
* </p>
*
* @dtf.tag.example
* <result uri="storage://OUTPUT/ut_results.xml" type="xml">
* <testsuite name="unittests" >
* <!-- Storage Tests -->
* <testscript uri="storage://INPUT/storage.xml"/>
* </testsuite>
* </result>
*
* @dtf.tag.example
* <result uri="storage://OUTPUT/ut_results.xml" type="junit">
* <testsuite name="unittests" >
* <!-- Storage Tests -->
* <testscript uri="storage://INPUT/storage.xml"/>
* </testsuite>
* </result>
*/
public class Result extends Action {
/**
* @dtf.attr uri
* @dtf.attr.desc The output URI to use for the results types that may need
* to output to a file.
*/
private String uri = null;
/**
* @dtf.attr type
* @dtf.attr.desc <p>
* The currently supported result output types:
* </p>
* <ul>
* <b>Result Types</b>
* <table border="1">
* <tr>
* <th>Type</th>
* <th>Description</th>
* </tr>
* <tr>
* <td>xml</td>
* <td>Outputs the testsuite/testcase results in an
* XML format that can later be processed and
* analyzed to generate easier to read results
* from the test execution.</td>
* </tr>
* <tr>
* <td>console</td>
* <td>Outputs the testsuite/testcase results to the
* Logger so that the user can see all testsuite
* and testcase results directly in his logs.
* </tr>
* <tr>
* <td>junit</td>
* <td>Outputs the testsuite/testcase results to the
* a format compatible with junit output. This is
* very useful for reusing tools that already
* took this type of input to generate reports.
* </tr>
* </table>
* </ul>
*/
private String type = null;
public Result() { }
public void execute() throws DTFException {
getLogger().info("Starting Result recording: " + this);
ResultsBase results = ResultsFactory.getRecorder(getType(),getUri());
pushResults(results);
try {
executeChildren();
} finally {
popResults();
}
getLogger().info("Stopping Result recording: " + this);
}
public String getType() throws ParseException { return replaceProperties(type); }
public void setType(String type) { this.type = type; }
public URI getUri() throws ActionException, ParseException { return parseURI(uri); }
public void setUri(String uri) { this.uri = uri; }
}