Search in sources :

Example 26 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_fail_syntax_error_file.

@Test(dataProvider = "supportedBitnessProvider")
public void should_fail_syntax_error_file(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "callToSomeNonExistentFunction(param1, param2)");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_LOG_ERR_TO_ERROR, "true");
    getBuildType().setOption(SBuildType.BT_FAIL_ON_ANY_ERROR_MESSAGE, true);
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isFailed());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Example 27 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-powershell by JetBrains.

the class BuildFailureTests method should_fail_on_error_output_file.

@Test(dataProvider = "supportedBitnessProvider")
public void should_fail_on_error_output_file(@NotNull final PowerShellBitness bitness) throws Throwable {
    setRunnerParameter(PowerShellConstants.RUNNER_EXECUTION_MODE, PowerShellExecutionMode.PS1.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_MODE, PowerShellScriptMode.CODE.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_SCRIPT_CODE, "$res = \"Epic fail\" \nWrite-Error $res");
    setRunnerParameter(PowerShellConstants.RUNNER_BITNESS, bitness.getValue());
    setRunnerParameter(PowerShellConstants.RUNNER_LOG_ERR_TO_ERROR, "true");
    getBuildType().setOption(SBuildType.BT_FAIL_ON_ANY_ERROR_MESSAGE, true);
    final SFinishedBuild build = doTest(null);
    dumpBuildLogLocally(build);
    Assert.assertTrue(build.getBuildStatus().isFailed());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) Test(org.testng.annotations.Test)

Example 28 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-rest by JetBrains.

the class TestOccurrenceRequestTest method testWithoutSessionUser.

@Test
public void testWithoutSessionUser() {
    final SFinishedBuild build = build().in(myBuildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).finish();
    FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
    mockRequest.setRequestURL("http://test/httpAuth/app/rest/testOccurrences?locator=build:" + build.getBuildId());
    TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:" + build.getBuildId(), "", null, mockRequest);
    assertEquals(new Integer(1), testOccurrences.getCount());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) Test(org.testng.annotations.Test)

Example 29 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-rest by JetBrains.

the class TestOccurrenceRequestTest method testTestOccurrenceFields.

@Test
public void testTestOccurrenceFields() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).withTest(BuildBuilder.TestData.test("bbb").out("std out").errorOut("str err").failed("error message", "stacktrace\nline 1\r\nline2").duration(67)).finish();
    {
        TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:(id:" + build10.getBuildId() + "),status:FAILURE", "**", null, null);
        assertEquals(Integer.valueOf(1), testOccurrences.getCount());
        assertEquals(1, testOccurrences.items.size());
        TestOccurrence testOccurrence = testOccurrences.items.get(0);
        assertEquals("bbb", testOccurrence.getName());
        // "2" should actually be here, but API cannot guarantee preservation of the number when not all tests are retrieved, so documenting the current behavior.
        assertEquals("1", testOccurrence.getRunOrder());
        assertEquals(Integer.valueOf(67), testOccurrence.getDuration());
        assertEquals("FAILURE", testOccurrence.getStatus());
        assertEquals(Boolean.valueOf(false), testOccurrence.getIgnored());
        assertNull(testOccurrence.getIgnoreDetails());
        assertEquals("error message\nstacktrace\nline 1\r\nline2\n------- Stdout: -------\nstd out\n------- Stderr: -------\nstr err", testOccurrence.getDetails());
    }
    final SFinishedBuild build20 = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).withTest(BuildBuilder.TestData.test("bbb").failed("error message", "stacktrace\nline 1\nline2").duration(67)).withTest(BuildBuilder.TestData.test("ccc").ignored("Ignore reason").out("std\r\nout").duration(67)).finish();
    {
        TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:(id:" + build20.getBuildId() + "),ignored:true", "**", null, null);
        assertEquals(Integer.valueOf(1), testOccurrences.getCount());
        assertEquals(1, testOccurrences.items.size());
        TestOccurrence testOccurrence = testOccurrences.items.get(0);
        assertEquals("ccc", testOccurrence.getName());
        assertEquals("3", testOccurrence.getRunOrder());
        assertEquals(Integer.valueOf(0), testOccurrence.getDuration());
        assertEquals("UNKNOWN", testOccurrence.getStatus());
        assertEquals(Boolean.valueOf(true), testOccurrence.getIgnored());
        assertEquals("Ignore reason", testOccurrence.getIgnoreDetails());
        assertNull(testOccurrence.getDetails());
    }
    // checking how ignored and failed test looks like. Just asserting current behavior
    final SFinishedBuild build30 = build().in(buildType).withTest(BuildBuilder.TestData.test("aaa").duration(76)).withTest(BuildBuilder.TestData.test("bbb").failed("error message", "stacktrace\nline 1\nline2").duration(67)).withTest(BuildBuilder.TestData.test("ccc").failed("error message", "stacktrace\nline 1\nline2").duration(67)).withTest(BuildBuilder.TestData.test("ccc").ignored("Ignore reason")).finish();
    {
        TestOccurrences testOccurrences = myRequest.getTestOccurrences("build:(id:" + build30.getBuildId() + "),test:(name:ccc)", "**", null, null);
        assertEquals(Integer.valueOf(1), testOccurrences.getCount());
        assertEquals(1, testOccurrences.items.size());
        TestOccurrence testOccurrence = testOccurrences.items.get(0);
        assertEquals("ccc", testOccurrence.getName());
        assertEquals("3", testOccurrence.getRunOrder());
        assertEquals(Integer.valueOf(67), testOccurrence.getDuration());
        assertEquals("FAILURE", testOccurrence.getStatus());
        assertEquals(Boolean.valueOf(false), testOccurrence.getIgnored());
        assertEquals("error message\nstacktrace\nline 1\nline2", testOccurrence.getDetails());
    }
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 30 with SFinishedBuild

use of jetbrains.buildServer.serverSide.SFinishedBuild in project teamcity-rest by JetBrains.

the class TestOccurrenceRequestTest method testInvocationsAreFoundCorrectly2.

@Test
@TestFor(issues = { "TW-70206" })
public void testInvocationsAreFoundCorrectly2() {
    if (true)
        throw new SkipException("Reverted correct behaviour due to TW-70587");
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build = build().in(buildType).withTest("aaa", false).withTest("aaa", false).withTest("aaa", true).finish();
    String fields = "testCounters(failed,success,all,duration),testOccurrence(id,name,muted,status,invocations($locator(count:90000),testCounters(all,success,failed),testOccurrence(id,name,status,muted)))";
    String locator = "currentlyFailing:true,affectedProject:" + buildType.getProject().getExternalId();
    FakeHttpServletRequest mockRequest = new FakeHttpServletRequest();
    mockRequest.setRequestURL(String.format("http://test/httpAuth/app/rest/testOccurrences?locator=%s&fields=%s", locator, fields));
    TestOccurrences testOccurrences = myRequest.getTestOccurrences(locator, fields, null, mockRequest);
    assertEquals("Should return exactly one 'grouping' test run.", 1, testOccurrences.items.size());
    TestOccurrence grouping = testOccurrences.items.get(0);
    assertNotNull("Should contain invocations node.", grouping.getInvocations());
    assertEquals("Should contain exactly 3 occurrences.", 3, grouping.getInvocations().items.size());
}
Also used : SFinishedBuild(jetbrains.buildServer.serverSide.SFinishedBuild) TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) FakeHttpServletRequest(jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest) TestOccurrences(jetbrains.buildServer.server.rest.model.problem.TestOccurrences) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) SkipException(org.testng.SkipException) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Aggregations

SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)34 Test (org.testng.annotations.Test)32 TestFor (jetbrains.buildServer.util.TestFor)12 BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)9 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)7 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)7 TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)4 Set (java.util.Set)3 Collectors (java.util.stream.Collectors)3 TestOccurrence (jetbrains.buildServer.server.rest.model.problem.TestOccurrence)3 BeanContext (jetbrains.buildServer.server.rest.util.BeanContext)2 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)2 SkipException (org.testng.SkipException)2 BufferedImage (java.awt.image.BufferedImage)1 SUserGroup (jetbrains.buildServer.groups.SUserGroup)1 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)1 Build (jetbrains.buildServer.server.rest.model.build.Build)1 User (jetbrains.buildServer.server.rest.model.user.User)1 BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)1 BuildTypeEx (jetbrains.buildServer.serverSide.BuildTypeEx)1