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();
}
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);
}
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);
}
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()));
}
}
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);
}
Aggregations