Search in sources :

Example 66 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testShortStatisticsIsNotEnoughWhenNoFieldsGiven.

@Test
@TestFor(issues = { "TW-71738" })
public void testShortStatisticsIsNotEnoughWhenNoFieldsGiven() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build = createBuildWithSuccessFailedIgnoredTests(buildType);
    assertNull("When fields are not given we can't use short statistics", myTestOccurrenceFinder.tryGetCachedInfo("build:" + build.getBuildId(), null).getShortStatistics());
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test) TestFor(jetbrains.buildServer.util.TestFor)

Example 67 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testByTestOccurrenceNameCondition.

@Test
public void testByTestOccurrenceNameCondition() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("aaabbb", true).withTest("aaa", true).withTest("AAA", true).withTest("bbb", true).withTest("(aaabbb)", true).finish();
    int idx = 1;
    check("build:(id:" + build10.getBuildId() + "),expandInvocations:true", TEST_MATCHER, t("aaabbb", Status.NORMAL, idx++), t("aaa", Status.NORMAL, idx++), t("AAA", Status.NORMAL, idx++), t("bbb", Status.NORMAL, idx++), t("(aaabbb)", Status.NORMAL, idx++));
    Checker test = new Checker<TestRunData, String>(nameDimension -> "build:(id:" + build10.getBuildId() + "),name:" + nameDimension, testName -> t(testName, Status.NORMAL, null), TEST_MATCHER);
    test.check("aaa", "aaa");
    test.check("aa");
    test.check("(value:aaa)", "aaa");
    test.check("(value:aaa,ignoreCase:true)", "aaa", "AAA");
    test.check("(value:aaa,matchType:starts-with)", "aaabbb", "aaa");
    test.check("(value:ab,matchType:contains)", "aaabbb", "(aaabbb)");
    test.check("(value:(aa),matchType:contains)", "aaabbb", "aaa", "(aaabbb)");
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 68 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testTestOccurrenceEntityInvocations.

@Test
public void testTestOccurrenceEntityInvocations() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("aaa", true).withTest("aaa", true).withTest("bbb", true).withTest("ccc", false).withTest("bbb", true).withTest("aaa", false).withTest("aaa", true).withTest("ddd", true).finish();
    STestRun testRunAAA = build10.getFullStatistics().getAllTests().get(0);
    {
        TestOccurrence testOccurrence = new TestOccurrence(testRunAAA, getBeanContext(myServer), new Fields("invocations($long)"));
        assertEquals(Integer.valueOf(4), testOccurrence.getInvocations().getCount());
        assertEquals(Integer.valueOf(1), testOccurrence.getInvocations().getFailed());
        assertNotNull(testOccurrence.getInvocations().items);
        assertEquals(4, testOccurrence.getInvocations().items.size());
        assertEquals("SUCCESS", testOccurrence.getInvocations().items.get(0).getStatus());
        assertEquals("FAILURE", testOccurrence.getInvocations().items.get(2).getStatus());
    }
    {
        TestOccurrence testOccurrence = new TestOccurrence(testRunAAA, getBeanContext(myServer), new Fields("invocations($long,$locator(status:FAILURE))"));
        assertEquals(Integer.valueOf(1), testOccurrence.getInvocations().getCount());
        assertNotNull(testOccurrence.getInvocations().items);
        assertEquals(1, testOccurrence.getInvocations().items.size());
        assertEquals("FAILURE", testOccurrence.getInvocations().items.get(0).getStatus());
    }
}
Also used : TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) Fields(jetbrains.buildServer.server.rest.model.Fields) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 69 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testShortStatisticsIsNotEnoughWhenThereIsMoreThanOneBuildInRequest.

@Test
public void testShortStatisticsIsNotEnoughWhenThereIsMoreThanOneBuildInRequest() {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build1 = createBuildWithSuccessFailedIgnoredTests(buildType);
    final SFinishedBuild build2 = createBuildWithSuccessFailedIgnoredTests(buildType);
    assertNull("ShortStatistics can be used only if there is a single build.", myTestOccurrenceFinder.tryGetCachedInfo("build:(status:failed)", "count,passed,failed,newFailed,ignored,muted").getShortStatistics());
}
Also used : BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Example 70 with BuildTypeImpl

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

the class TestOccurrenceFinderTest method testTestNameDetails.

@Test
public void testTestNameDetails() throws Exception {
    final BuildTypeImpl buildType = registerBuildType("buildConf1", "project");
    final SFinishedBuild build10 = build().in(buildType).withTest("com.jetbrains.teamcity.MyClass.method1", false).withTest("com.jetbrains.teamcity.MyClass.method2", true).finish();
    check("build:(id:" + build10.getBuildId() + ")", TEST_MATCHER, t("com.jetbrains.teamcity.MyClass.method1", Status.FAILURE, 1), t("com.jetbrains.teamcity.MyClass.method2", Status.NORMAL, 2));
    STestRun method1 = build10.getFullStatistics().getAllTests().get(0);
    STestRun method2 = build10.getFullStatistics().getAllTests().get(1);
    {
        TestOccurrence testOccurrence = new TestOccurrence(method1, getBeanContext(myServer), new Fields("test(id,name)"));
        // if we didn't ask for parsed test name - the object will be not filled
        assertNull(testOccurrence.getTest().getParsedTestName());
    }
    {
        TestOccurrence testOccurrence = new TestOccurrence(method1, getBeanContext(myServer), new Fields("test(id,name,parsedTestName)"));
        assertNotNull(testOccurrence.getTest().getParsedTestName());
        assertEquals("MyClass", testOccurrence.getTest().getParsedTestName().testClass);
        assertEquals("method1", testOccurrence.getTest().getParsedTestName().testMethodName);
    }
    {
        TestOccurrence testOccurrence = new TestOccurrence(method2, getBeanContext(myServer), new Fields("test(id,name,parsedTestName)"));
        assertNotNull(testOccurrence.getTest().getParsedTestName());
        assertEquals("MyClass", testOccurrence.getTest().getParsedTestName().testClass);
        assertEquals("method2", testOccurrence.getTest().getParsedTestName().testMethodName);
    }
}
Also used : TestOccurrence(jetbrains.buildServer.server.rest.model.problem.TestOccurrence) Fields(jetbrains.buildServer.server.rest.model.Fields) BuildTypeImpl(jetbrains.buildServer.serverSide.impl.BuildTypeImpl) Test(org.testng.annotations.Test)

Aggregations

BuildTypeImpl (jetbrains.buildServer.serverSide.impl.BuildTypeImpl)80 Test (org.testng.annotations.Test)68 BaseFinderTest (jetbrains.buildServer.server.rest.data.BaseFinderTest)19 BadRequestException (jetbrains.buildServer.server.rest.errors.BadRequestException)12 ChangeStatus (jetbrains.buildServer.server.rest.model.change.ChangeStatus)12 SVcsModification (jetbrains.buildServer.vcs.SVcsModification)12 VcsRootInstance (jetbrains.buildServer.vcs.VcsRootInstance)12 SUser (jetbrains.buildServer.users.SUser)11 MockVcsSupport (jetbrains.buildServer.serverSide.impl.MockVcsSupport)10 SFinishedBuild (jetbrains.buildServer.serverSide.SFinishedBuild)9 TestOccurrence (jetbrains.buildServer.server.rest.model.problem.TestOccurrence)7 ProjectEx (jetbrains.buildServer.serverSide.impl.ProjectEx)7 TestFor (jetbrains.buildServer.util.TestFor)7 BuildPromotionEx (jetbrains.buildServer.serverSide.BuildPromotionEx)6 TestOccurrences (jetbrains.buildServer.server.rest.model.problem.TestOccurrences)5 RunningBuildEx (jetbrains.buildServer.serverSide.RunningBuildEx)5 Set (java.util.Set)4 Collectors (java.util.stream.Collectors)4 FakeHttpServletRequest (jetbrains.buildServer.controllers.fakes.FakeHttpServletRequest)4 TestScope (jetbrains.buildServer.server.rest.data.problem.scope.TestScope)4