Search in sources :

Example 1 with TestSuite

use of com.thoughtworks.go.domain.testinfo.TestSuite in project gocd by gocd.

the class StageNotificationServiceTest method shouldHaveFailedTestsSectionWhenShineIsEnabledAndThereAreFailedTests.

@Test
public void shouldHaveFailedTestsSectionWhenShineIsEnabledAndThereAreFailedTests() {
    String mail = prepareOneMatchedUser();
    stubPipelineAndStage(new Date());
    when(systemEnvironment.isShineEnabled()).thenReturn(true);
    ArrayList<TestSuite> testSuites = new ArrayList<>();
    testSuites.add(new TestSuite("blah"));
    when(shineDao.failedTestsFor(stageIdentifier)).thenReturn(testSuites);
    stageNotificationService.sendNotifications(stageIdentifier, StageEvent.Fails, new Username(new CaseInsensitiveString("loser")));
    String body = inMemoryEmailNotificationTopic.getBody(mail);
    assertThat(body, containsString(StageNotificationService.FAILED_TEST_SECTION));
}
Also used : TestSuite(com.thoughtworks.go.domain.testinfo.TestSuite) Username(com.thoughtworks.go.server.domain.Username) ArrayList(java.util.ArrayList) Matchers.anyString(org.mockito.Matchers.anyString) StringContains.containsString(org.hamcrest.core.StringContains.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 2 with TestSuite

use of com.thoughtworks.go.domain.testinfo.TestSuite in project gocd by gocd.

the class StageNotificationServiceTest method shouldSendEmailWithFailureDetails.

@Test
public void shouldSendEmailWithFailureDetails() throws Exception {
    final String expectedBaseUrl = "http://test.host:8153";
    String jezMail = prepareOneMatchedUser();
    final Date date = new Date();
    stubPipelineAndStage(date);
    final TestSuite suite1 = new TestSuite("com.thoughtworks.go.FailOne");
    suite1.addTest("shouldCompile", TestStatus.Error, new JobIdentifier(stageIdentifier, "compile"));
    suite1.addTest("shouldPass", TestStatus.Failure, new JobIdentifier(stageIdentifier, "test"));
    suite1.addTest("shouldPass", TestStatus.Failure, new JobIdentifier(stageIdentifier, "twist"));
    suite1.addTest("shouldCompile2", TestStatus.Failure, new JobIdentifier(stageIdentifier, "compile"));
    final TestSuite suite2 = new TestSuite("com.thoughtworks.go.FailTwo");
    suite2.addTest("shouldCompile", TestStatus.Error, new JobIdentifier(stageIdentifier, "test"));
    suite2.addTest("shouldTest", TestStatus.Failure, new JobIdentifier(stageIdentifier, "test"));
    when(serverConfigService.siteUrlFor(anyString(), eq(false))).thenAnswer(new Answer<String>() {

        public String answer(InvocationOnMock invocation) throws Throwable {
            Object[] args = invocation.getArguments();
            return morphURl((String) args[0], expectedBaseUrl);
        }
    });
    when(systemEnvironment.isShineEnabled()).thenReturn(true);
    when(shineDao.failedTestsFor(stageIdentifier)).thenReturn(Arrays.asList(suite1, suite2));
    stageNotificationService.sendNotifications(stageIdentifier, StageEvent.Fails, new Username(new CaseInsensitiveString("loser")));
    String body = inMemoryEmailNotificationTopic.getBody(jezMail);
    assertThat(body, containsString(StageNotificationService.FAILED_TEST_SECTION));
    String restOfThebody = textAfter(body, StageNotificationService.FAILED_TEST_SECTION);
    String failuresText = restOfThebody.substring(0, restOfThebody.indexOf(StageNotificationService.MATERIAL_SECTION_HEADER));
    assertEquals("\n\nThe following tests failed in pipeline 'go' (instance 'go-1'):\n\n" + "* com.thoughtworks.go.FailOne\n" + "   shouldCompile\n" + "     Errored on 'compile' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/compile)\n" + "   shouldCompile2\n" + "     Failed on 'compile' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/compile)\n" + "   shouldPass\n" + "     Failed on 'test' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/test)\n" + "     Failed on 'twist' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/twist)\n" + "\n\n* com.thoughtworks.go.FailTwo\n" + "   shouldCompile\n" + "     Errored on 'test' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/test)\n" + "   shouldTest\n" + "     Failed on 'test' (" + expectedBaseUrl + "/go/tab/build/detail/go/1/dev/2/test)\n\n\n", failuresText);
}
Also used : TestSuite(com.thoughtworks.go.domain.testinfo.TestSuite) Username(com.thoughtworks.go.server.domain.Username) InvocationOnMock(org.mockito.invocation.InvocationOnMock) Matchers.anyString(org.mockito.Matchers.anyString) StringContains.containsString(org.hamcrest.core.StringContains.containsString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 3 with TestSuite

use of com.thoughtworks.go.domain.testinfo.TestSuite in project gocd by gocd.

the class ShineDaoIntegrationTest method shouldBeAbleToRetriveStageTestRunsWithLazyGraphLoader.

@Test
public void shouldBeAbleToRetriveStageTestRunsWithLazyGraphLoader() throws Exception {
    StageTestRuns stageTestRuns = shineDao.failedBuildHistoryForStage(stageId, result);
    List<FailingTestsInPipeline> failingTestsInPipelines = stageTestRuns.failingTestsInPipelines();
    assertThat(failingTestsInPipelines.toString(), failingTestsInPipelines.size(), is(1));
    List<TestSuite> suites = failingTestsInPipelines.get(0).failingSuites();
    assertThat(suites.size(), is(1));
    assertThat(suites.get(0).fullName(), is("testSuite1"));
    List<TestInformation> tests = suites.get(0).tests();
    assertThat(tests.size(), is(2));
    assertThat(tests.get(0).getName(), is("test1"));
    assertThat(tests.get(0).getStatus(), is(TestStatus.Failure));
    assertThat(tests.get(0).getJobNames(), hasItems("NixBuild", "WinBuild"));
    assertThat(tests.get(1).getName(), is("test2"));
    assertThat(tests.get(1).getStatus(), is(TestStatus.Error));
    assertThat(tests.get(1).getJobNames(), hasItems("WinBuild"));
}
Also used : TestInformation(com.thoughtworks.go.domain.testinfo.TestInformation) TestSuite(com.thoughtworks.go.domain.testinfo.TestSuite) StageTestRuns(com.thoughtworks.go.domain.testinfo.StageTestRuns) FailingTestsInPipeline(com.thoughtworks.go.domain.testinfo.FailingTestsInPipeline) Test(org.junit.Test)

Aggregations

TestSuite (com.thoughtworks.go.domain.testinfo.TestSuite)3 Test (org.junit.Test)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 Username (com.thoughtworks.go.server.domain.Username)2 Date (java.util.Date)2 StringContains.containsString (org.hamcrest.core.StringContains.containsString)2 Matchers.anyString (org.mockito.Matchers.anyString)2 FailingTestsInPipeline (com.thoughtworks.go.domain.testinfo.FailingTestsInPipeline)1 StageTestRuns (com.thoughtworks.go.domain.testinfo.StageTestRuns)1 TestInformation (com.thoughtworks.go.domain.testinfo.TestInformation)1 ArrayList (java.util.ArrayList)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1