Search in sources :

Example 1 with BuildTestSuite

use of com.thoughtworks.go.server.domain.BuildTestSuite in project gocd by gocd.

the class LogParserTest method testCanReadFailure.

@Test
public void testCanReadFailure() throws Exception {
    LogFile logFile = new LogFile(DataUtils.getFailedBuildLbuildAsFile().getFile());
    boolean isPassed = false;
    Map map = logParser.parseLogFile(logFile, isPassed);
    List suites = getTestSuites(map);
    BuildTestSuite firstSuite = (BuildTestSuite) suites.get(0);
    List failingCases = firstSuite.getFailingTestCases();
    assertThat(firstSuite.getNumberOfFailures(), is(3));
    assertThat(failingCases.size(), is(3));
    BuildTestCase failingTest = (BuildTestCase) failingCases.get(0);
    String expectedNoClassDefFoundError = "junit.framework.AssertionFailedError: Error during schema validation";
    String exptectedClassPath = "at junit.framework.Assert.fail(Assert.java:47)";
    String className = "net.sourceforge.cruisecontrol.sampleproject.connectfour.PlayingStandTest";
    assertThat(failingTest.getClassname(), is(className));
    assertThat(failingTest.getDuration(), is("3.807"));
    assertThat(failingTest.getName(), is("testSomething"));
    assertThat(failingTest.getResult(), is(BuildTestCaseResult.FAILED));
    assertThat(failingTest.getMessage(), is("Not the expected result"));
    assertThat(failingTest.getMessageBody(), containsString(expectedNoClassDefFoundError));
    assertThat(failingTest.getMessageBody(), containsString(exptectedClassPath));
}
Also used : LogFile(com.thoughtworks.go.server.domain.LogFile) BuildTestSuite(com.thoughtworks.go.server.domain.BuildTestSuite) BuildTestCase(com.thoughtworks.go.server.domain.BuildTestCase) List(java.util.List) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Map(java.util.Map) Test(org.junit.Test)

Example 2 with BuildTestSuite

use of com.thoughtworks.go.server.domain.BuildTestSuite in project gocd by gocd.

the class JobInstanceLog method getNumberOfFailures.

public int getNumberOfFailures() {
    int numberOfFailures = 0;
    List testSuites = getTestSuites();
    for (int i = 0; i < testSuites.size(); i++) {
        BuildTestSuite suite = (BuildTestSuite) testSuites.get(i);
        numberOfFailures += suite.getNumberOfFailures();
    }
    return numberOfFailures;
}
Also used : BuildTestSuite(com.thoughtworks.go.server.domain.BuildTestSuite) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with BuildTestSuite

use of com.thoughtworks.go.server.domain.BuildTestSuite in project gocd by gocd.

the class JobInstanceLog method getNumberOfTests.

public int getNumberOfTests() {
    int totalNumberOfTests = 0;
    List testSuites = getTestSuites();
    for (int i = 0; i < testSuites.size(); i++) {
        BuildTestSuite suite = (BuildTestSuite) testSuites.get(i);
        totalNumberOfTests += suite.getNumberOfTests();
    }
    return totalNumberOfTests;
}
Also used : BuildTestSuite(com.thoughtworks.go.server.domain.BuildTestSuite) ArrayList(java.util.ArrayList) List(java.util.List)

Example 4 with BuildTestSuite

use of com.thoughtworks.go.server.domain.BuildTestSuite in project gocd by gocd.

the class JobInstanceLog method getNumberOfErrors.

public int getNumberOfErrors() {
    int numberOfErrors = 0;
    List testSuites = getTestSuites();
    for (int i = 0; i < testSuites.size(); i++) {
        BuildTestSuite suite = (BuildTestSuite) testSuites.get(i);
        numberOfErrors += suite.getNumberOfErrors();
    }
    return numberOfErrors;
}
Also used : BuildTestSuite(com.thoughtworks.go.server.domain.BuildTestSuite) ArrayList(java.util.ArrayList) List(java.util.List)

Example 5 with BuildTestSuite

use of com.thoughtworks.go.server.domain.BuildTestSuite in project gocd by gocd.

the class LogParserTest method testCanReadError.

@Test
public void testCanReadError() throws Exception {
    LogFile logFile = new LogFile(DataUtils.getFailedBuildLbuildAsFile().getFile());
    boolean isPassed = false;
    Map map = logParser.parseLogFile(logFile, isPassed);
    List suites = getTestSuites(map);
    BuildTestSuite firstSuite = (BuildTestSuite) suites.get(0);
    List erroringTestCases = firstSuite.getErrorTestCases();
    assertThat(erroringTestCases.size(), is(1));
    BuildTestCase erroredTest = (BuildTestCase) erroringTestCases.get(0);
    String expectedClassName = "net.sourceforge.cruisecontrol.sampleproject.connectfour.PlayingStandTest";
    String expectedNoClassDefFoundError = "java.lang.NoClassDefFoundError: org/objectweb/asm/CodeVisitor";
    String exptectedClassPath = "at net.sf.cglib.core.KeyFactory$Generator.generateClass(KeyFactory.java:165)";
    assertThat(erroredTest.getClassname(), is(expectedClassName));
    assertThat(erroredTest.getDuration(), is("0.016"));
    assertThat(erroredTest.getName(), is("testFourConnected"));
    assertThat(erroredTest.didError(), is(true));
    assertThat(erroredTest.getMessage(), is("org/objectweb/asm/CodeVisitor"));
    assertThat(erroredTest.getMessageBody(), containsString(expectedNoClassDefFoundError));
    assertThat(erroredTest.getMessageBody(), containsString(exptectedClassPath));
}
Also used : LogFile(com.thoughtworks.go.server.domain.LogFile) BuildTestSuite(com.thoughtworks.go.server.domain.BuildTestSuite) BuildTestCase(com.thoughtworks.go.server.domain.BuildTestCase) List(java.util.List) StringContains.containsString(org.hamcrest.core.StringContains.containsString) Map(java.util.Map) Test(org.junit.Test)

Aggregations

BuildTestSuite (com.thoughtworks.go.server.domain.BuildTestSuite)5 List (java.util.List)5 ArrayList (java.util.ArrayList)3 BuildTestCase (com.thoughtworks.go.server.domain.BuildTestCase)2 LogFile (com.thoughtworks.go.server.domain.LogFile)2 Map (java.util.Map)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 Test (org.junit.Test)2