Search in sources :

Example 1 with Iteration

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

the class TestCampaign method testGetAllIterationsWithError.

@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testGetAllIterationsWithError() {
    GetRequest getRequest = (GetRequest) createServerMock("GET", "/campaign/7/iterations", 200, "{}", "requestBodyEntity");
    when(getRequest.asPaged(any(), (Function<HttpResponse<JsonNode>, String>) any(Function.class))).thenThrow(UnirestException.class);
    Campaign campaign = new Campaign("http://localhost:4321/campaign/7", 7, "campaign");
    List<Iteration> iterations = campaign.getIterations();
}
Also used : Campaign(com.seleniumtests.connectors.tms.squash.entities.Campaign) GetRequest(kong.unirest.GetRequest) HttpResponse(kong.unirest.HttpResponse) 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 2 with Iteration

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

the class TestIteration method testGetAllNoTestCases.

/**
 * Check case where no campaigns are available
 */
@Test(groups = { "ut" })
public void testGetAllNoTestCases() {
    createServerMock("GET", "/iterations/1/test-plan", 200, "{" + "  \"_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(), 0);
}
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 3 with Iteration

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

the class TestIterationTestPlanItem method testCreateIterationTestPlanItem.

@Test(groups = { "ut" })
public void testCreateIterationTestPlanItem() {
    HttpRequestWithBody postRequest = (HttpRequestWithBody) createServerMock("POST", "/iterations/4/test-plan", 200, "{" + "  \"_type\" : \"iteration-test-plan-item\"," + "  \"id\" : 38," + "  \"execution_status\" : \"READY\"," + "  \"referenced_test_case\" : {" + "    \"_type\" : \"test-case\"," + "    \"id\" : 25," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/25\"" + "      }" + "    }" + "  }," + "  \"referenced_dataset\" : {" + "    \"_type\" : \"dataset\"," + "    \"id\" : 3," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/datasets/3\"" + "      }" + "    }" + "  }," + "  \"last_executed_by\" : null," + "  \"last_executed_on\" : null," + "  \"assigned_to\" : \"User-1\"," + "  \"executions\" : [ ]," + "  \"iteration\" : {" + "    \"_type\" : \"iteration\"," + "    \"id\" : 4," + "    \"_links\" : {" + "      \"self\" : {" + "        \"href\" : \"http://localhost:8080/api/rest/latest/iterations/4\"" + "      }" + "    }" + "  }," + "  \"_links\" : {" + "    \"self\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/38\"" + "    }," + "    \"project\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/projects/14\"" + "    }," + "    \"test-case\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/test-cases/25\"" + "    }," + "    \"dataset\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/datasets/3\"" + "    }," + "    \"iteration\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iterations/4\"" + "    }," + "    \"executions\" : {" + "      \"href\" : \"http://localhost:8080/api/rest/latest/iteration-test-plan-items/38/executions\"" + "    }" + "  }" + "}", "request");
    Iteration iteration = new Iteration("http://localhost:8080/api/rest/latest/iterations/4", 4, "my_iteration");
    IterationTestPlanItem itpi = IterationTestPlanItem.create(iteration, new TestCase(25, "http://localhost:8080/api/rest/latest/test-cases/25"));
    verify(postRequest).body(new JSONObject("{\"_type\":\"iteration-test-plan-item\",\"test_case\":{\"id\":25,\"_type\":\"test-case\"}}"));
    Assert.assertEquals(itpi.getId(), 38);
}
Also used : IterationTestPlanItem(com.seleniumtests.connectors.tms.squash.entities.IterationTestPlanItem) JSONObject(kong.unirest.json.JSONObject) TestCase(com.seleniumtests.connectors.tms.squash.entities.TestCase) HttpRequestWithBody(kong.unirest.HttpRequestWithBody) 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 4 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration 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 5 with Iteration

use of com.seleniumtests.connectors.tms.squash.entities.Iteration 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)

Aggregations

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