All Downloads are FREE. Search and download functionalities are using the official Maven repository.

hudson.tasks.junit.CaseResult Maven / Gradle / Ivy

package hudson.tasks.junit;

import hudson.model.Build;
import org.dom4j.Element;

import java.util.Comparator;

/**
 * One test result.
 *
 * @author Kohsuke Kawaguchi
 */
public final class CaseResult extends TestObject implements Comparable {
    private final String className;
    private final String testName;
    private final String errorStackTrace;
    private transient SuiteResult parent;

    private transient ClassResult classResult;

    /**
     * This test has been failing since this build number (not id.)
     *
     * If {@link #isPassed() passing}, this field is left unused to 0.
     */
    private /*final*/ int failedSince;

    CaseResult(SuiteResult parent, Element testCase) {
        String cn = testCase.attributeValue("classname");
        if(cn==null)
            // Maven seems to skip classname, and that shows up in testSuite/@name
            cn = parent.getName();
        className = cn.replace('/','_');    // avoid unsafe chars
        testName = testCase.attributeValue("name").replace('/','_');
        errorStackTrace = getError(testCase);
    }

    private String getError(Element testCase) {
        String msg = testCase.elementText("error");
        if(msg!=null)
            return msg;
        return testCase.elementText("failure");
    }

    public String getDisplayName() {
        return testName;
    }

    /**
     * Gets the name of the test, which is returned from {@code TestCase.getName()}
     *
     * 

* Note that this may contain any URL-unfriendly character. */ public String getName() { return testName; } /** * Gets the version of {@link #getName()} that's URL-safe. */ public String getSafeName() { StringBuffer buf = new StringBuffer(testName); for( int i=0; i BY_AGE = new Comparator() { public int compare(CaseResult lhs, CaseResult rhs) { return lhs.getAge()-rhs.getAge(); } }; }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy