Search in sources :

Example 6 with IterationTestPlanItem

use of com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem in project seleniumRobot by bhecquet.

the class SquashTMConnector method recordResult.

@Override
public void recordResult(ITestResult testResult) {
    try {
        SquashTMApi sapi = getApi();
        Integer testId = TestNGResultUtils.getTestCaseId(testResult);
        if (testId == null) {
            return;
        }
        Campaign campaign = sapi.createCampaign("Selenium " + testResult.getTestContext().getName(), "");
        Iteration iteration = sapi.createIteration(campaign, TestNGResultUtils.getSeleniumRobotTestContext(testResult).getApplicationVersion());
        IterationTestPlanItem tpi = sapi.addTestCaseInIteration(iteration, testId);
        if (testResult.isSuccess()) {
            sapi.setExecutionResult(tpi, ExecutionStatus.SUCCESS);
        } else if (testResult.getStatus() == 2) {
            // failed
            sapi.setExecutionResult(tpi, ExecutionStatus.FAILURE);
        } else {
            // skipped or other reason
            sapi.setExecutionResult(tpi, ExecutionStatus.BLOCKED);
        }
    } catch (Exception e) {
        logger.error(String.format("Could not record result for test method %s: %s", TestNGResultUtils.getTestName(testResult), e.getMessage()));
    }
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) ConfigurationException(com.seleniumtests.customexception.ConfigurationException)

Example 7 with IterationTestPlanItem

use of com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem in project seleniumRobot by bhecquet.

the class TestSquashTM method testCreateCampaign.

@Test(groups = "no-ti", enabled = false, attributes = { @CustomAttribute(name = "testId", values = "12") })
public void testCreateCampaign(ITestContext testContext) {
    SquashTMConnector tm = new SquashTMConnector("http://localhost:8080/squash", "admin", "admin", "Test Project-1");
    SquashTMApi api = tm.getApi();
    Campaign campaign = api.createCampaign("AutoTest", "SubFolder/foo");
    Iteration iteration = api.createIteration(campaign, "myiteration");
    IterationTestPlanItem tpi = api.addTestCaseInIteration(iteration, 239);
    api.setExecutionResult(tpi, ExecutionStatus.FAILURE);
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) SquashTMConnector(com.seleniumtests.connectors.tms.squash.SquashTMConnector) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 8 with IterationTestPlanItem

use of com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem in project seleniumRobot by bhecquet.

the class TestIteration method testGetAllTestCases.

@Test(groups = { "ut" })
public void testGetAllTestCases() {
    createServerMock("GET", "/iterations/1/test-plan", 200, "{" + "  \"_embedded\" : {" + "    \"test-plan\" : [ {" + "      \"_type\" : \"iteration-test-plan-item\"," + "      \"id\" : 4," + "      \"execution_status\" : \"READY\"," + "      \"referenced_test_case\" : {" + "        \"_type\" : \"test-case\"," + "        \"id\" : 8," + "        \"name\" : \"sample test case 8\"," + "        \"reference\" : \"TC-8\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/8\"" + "          }" + "        }" + "      }," + "      \"referenced_dataset\" : {" + "        \"_type\" : \"dataset\"," + "        \"id\" : 90," + "        \"name\" : \"sample dataset 90\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/datasets/90\"" + "          }" + "        }" + "      }," + "      \"last_executed_by\" : \"User-1\"," + "      \"last_executed_on\" : \"2017-06-25T10:00:00.000+0000\"," + "      \"assigned_to\" : \"User-1\"," + "      \"executions\" : [ {" + "        \"_type\" : \"execution\"," + "        \"id\" : 2," + "        \"execution_status\" : \"BLOCKED\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-24T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/2\"" + "          }" + "        }" + "      }, {" + "        \"_type\" : \"execution\"," + "        \"id\" : 3," + "        \"execution_status\" : \"SUCCESS\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-25T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/3\"" + "          }" + "        }" + "      } ]," + "      \"iteration\" : {" + "        \"_type\" : \"iteration\"," + "        \"id\" : 1," + "        \"name\" : \"sample iteration\"," + "        \"reference\" : \"IT1\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1\"" + "          }" + "        }" + "      }," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/4\"" + "        }" + "      }" + "    }, {" + "      \"_type\" : \"iteration-test-plan-item\"," + "      \"id\" : 12," + "      \"execution_status\" : \"READY\"," + "      \"referenced_test_case\" : {" + "        \"_type\" : \"test-case\"," + "        \"id\" : 16," + "        \"name\" : \"sample test case 16\"," + "        \"reference\" : \"TC-16\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/16\"" + "          }" + "        }" + "      }," + "      \"referenced_dataset\" : {" + "        \"_type\" : \"dataset\"," + "        \"id\" : 12," + "        \"name\" : \"sample dataset 12\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/datasets/12\"" + "          }" + "        }" + "      }," + "      \"last_executed_by\" : \"User-1\"," + "      \"last_executed_on\" : \"2017-06-28T10:00:00.000+0000\"," + "      \"assigned_to\" : \"User-1\"," + "      \"executions\" : [ {" + "        \"_type\" : \"execution\"," + "        \"id\" : 9," + "        \"execution_status\" : \"FAILURE\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-26T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/9\"" + "          }" + "        }" + "      }, {" + "        \"_type\" : \"execution\"," + "        \"id\" : 35," + "        \"execution_status\" : \"SUCCESS\"," + "        \"last_executed_by\" : \"User-1\"," + "        \"last_executed_on\" : \"2017-06-28T10:00:00.000+0000\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/executions/35\"" + "          }" + "        }" + "      } ]," + "      \"iteration\" : {" + "        \"_type\" : \"iteration\"," + "        \"id\" : 1," + "        \"name\" : \"sample iteration\"," + "        \"reference\" : \"IT1\"," + "        \"_links\" : {" + "          \"self\" : {" + "            \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1\"" + "          }" + "        }" + "      }," + "      \"_links\" : {" + "        \"self\" : {" + "          \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/12\"" + "        }" + "      }" + "    } ]" + "  }," + "  \"_links\" : {" + "    \"first\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=0&size=2\"" + "    }," + "    \"prev\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=0&size=2\"" + "    }," + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=1&size=2\"" + "    }," + "    \"next\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=2&size=2\"" + "    }," + "    \"last\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/1/test-plan?page=2&size=2\"" + "    }" + "  }," + "  \"page\" : {" + "    \"size\" : 2," + "    \"totalElements\" : 6," + "    \"totalPages\" : 3," + "    \"number\" : 1" + "  }" + "}");
    Iteration iteration = new Iteration("http://localhost:8080/api/rest/latest/iterations/1", 1, "my_iteration");
    List<IterationTestPlanItem> testCases = iteration.getAllTestCases();
    Assert.assertEquals(testCases.size(), 2);
    Assert.assertEquals(testCases.get(0).getTestCase().getId(), 8);
    Assert.assertEquals(testCases.get(0).getId(), 4);
    Assert.assertEquals(testCases.get(0).getUrl(), "http://localhost:8080/api/rest/latest/iteration-test-plan-items/4");
}
Also used : IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) Iteration(com.seleniumtests.connectors.tms.squash.entities.Iteration) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 9 with IterationTestPlanItem

use of com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem in project seleniumRobot by bhecquet.

the class TestSquashTMApi method testDoNotAddTestCase.

/**
 * Iteration already exist, do not recreate it
 */
@Test(groups = { "ut" })
public void testDoNotAddTestCase() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    doReturn(Arrays.asList(testPlanItem1, testPlanItem2)).when(iteration1).getAllTestCases();
    PowerMockito.when(TestCase.get(3)).thenReturn(testCase1);
    doReturn(testPlanItem1).when(iteration1).addTestCase(testCase1);
    IterationTestPlanItem itpi = api.addTestCaseInIteration(iteration1, 2);
    Assert.assertEquals(itpi, testPlanItem2);
    // check test case has been added
    verify(iteration1, never()).addTestCase(any(TestCase.class));
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) TestCase(com.seleniumtests.connectors.tms.squash.entities.TestCase) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 10 with IterationTestPlanItem

use of com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem in project seleniumRobot by bhecquet.

the class TestSquashTMApi method testCannotAddTestCaseDoesNotExist.

/**
 * Check exception is raised if test case does not exist
 */
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testCannotAddTestCaseDoesNotExist() {
    PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
    SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
    doReturn(Arrays.asList(testPlanItem1, testPlanItem2)).when(iteration1).getAllTestCases();
    PowerMockito.doThrow(new ScenarioException("")).when(TestCase.class);
    TestCase.get(3);
    doReturn(testPlanItem1).when(iteration1).addTestCase(any(TestCase.class));
    IterationTestPlanItem itpi = api.addTestCaseInIteration(iteration1, 3);
}
Also used : SquashTMApi(com.seleniumtests.connectors.tms.squash.SquashTMApi) IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) TestCase(com.seleniumtests.connectors.tms.squash.entities.TestCase) ScenarioException(com.seleniumtests.customexception.ScenarioException) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

IterationTestPlanItem (com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem)12 Test (org.testng.annotations.Test)11 ConnectorsTest (com.seleniumtests.ConnectorsTest)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 TestCase (com.seleniumtests.connectors.tms.squash.entities.TestCase)7 Iteration (com.seleniumtests.connectors.tms.squash.entities.Iteration)5 SquashTMApi (com.seleniumtests.connectors.tms.squash.SquashTMApi)4 HttpRequestWithBody (kong.unirest.HttpRequestWithBody)3 JSONObject (kong.unirest.json.JSONObject)3 Campaign (com.seleniumtests.connectors.tms.squash.entities.Campaign)2 TestPlanItemExecution (com.seleniumtests.connectors.tms.squash.entities.TestPlanItemExecution)2 GenericTest (com.seleniumtests.GenericTest)1 SquashTMConnector (com.seleniumtests.connectors.tms.squash.SquashTMConnector)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 ScenarioException (com.seleniumtests.customexception.ScenarioException)1