Search in sources :

Example 1 with Data

use of hudson.tasks.junit.TestResultAction.Data in project hudson-2.x by hudson.

the class JUnitResultArchiver method perform.

@Override
public boolean perform(AbstractBuild build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
    listener.getLogger().println(Messages.JUnitResultArchiver_Recording());
    TestResultAction action;
    final String testResults = build.getEnvironment(listener).expand(this.testResults);
    try {
        TestResult result = parse(testResults, build, launcher, listener);
        try {
            action = new TestResultAction(build, result, listener);
        } catch (NullPointerException npe) {
            throw new AbortException(Messages.JUnitResultArchiver_BadXML(testResults));
        }
        result.freeze(action);
        if (result.getPassCount() == 0 && result.getFailCount() == 0)
            throw new AbortException(Messages.JUnitResultArchiver_ResultIsEmpty());
        // TODO: Move into JUnitParser [BUG 3123310]
        List<Data> data = new ArrayList<Data>();
        if (testDataPublishers != null) {
            for (TestDataPublisher tdp : testDataPublishers) {
                Data d = tdp.getTestData(build, launcher, listener, result);
                if (d != null) {
                    data.add(d);
                }
            }
        }
        action.setData(data);
        CHECKPOINT.block();
    } catch (AbortException e) {
        if (build.getResult() == Result.FAILURE)
            // don't report confusing error message.
            return true;
        listener.getLogger().println(e.getMessage());
        build.setResult(Result.FAILURE);
        return true;
    } catch (IOException e) {
        e.printStackTrace(listener.error("Failed to archive test reports"));
        build.setResult(Result.FAILURE);
        return true;
    }
    build.getActions().add(action);
    CHECKPOINT.report();
    if (action.getResult().getFailCount() > 0)
        build.setResult(Result.UNSTABLE);
    return true;
}
Also used : ArrayList(java.util.ArrayList) Data(hudson.tasks.junit.TestResultAction.Data) IOException(java.io.IOException) AbortException(hudson.AbortException)

Aggregations

AbortException (hudson.AbortException)1 Data (hudson.tasks.junit.TestResultAction.Data)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1