use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestSquashTMConnector method testRecordResultTestSkipped.
@Test(groups = { "ut" })
public void testRecordResultTestSkipped(ITestContext testContext) {
JSONObject connect = new JSONObject();
connect.put(SquashTMConnector.TMS_SERVER_URL, "http://myServer");
connect.put(SquashTMConnector.TMS_PROJECT, "project");
connect.put(SquashTMConnector.TMS_USER, "user");
connect.put(SquashTMConnector.TMS_PASSWORD, "password");
SquashTMConnector squash = spy(new SquashTMConnector());
squash.init(connect);
doReturn(api).when(squash).getApi();
CustomAttribute testIdAttr = new CustomAttribute() {
@Override
public Class<? extends Annotation> annotationType() {
return null;
}
@Override
public String[] values() {
return new String[] { "1" };
}
@Override
public String name() {
return "testId";
}
};
// customize test result so that it has attributes
when(testResult.getMethod()).thenReturn(testMethod);
when(testResult.isSuccess()).thenReturn(false);
when(testResult.getStatus()).thenReturn(3);
when(testResult.getName()).thenReturn("MyTest");
when(testResult.getTestContext()).thenReturn(testContext);
when(testResult.getParameters()).thenReturn(new Object[] {});
when(testResult.getAttribute("testContext")).thenReturn(SeleniumTestsContextManager.getThreadContext());
when(testMethod.getAttributes()).thenReturn(new CustomAttribute[] { testIdAttr });
when(api.createCampaign(anyString(), anyString())).thenReturn(campaign);
when(api.createIteration(any(Campaign.class), anyString())).thenReturn(iteration);
when(api.addTestCaseInIteration(iteration, 1)).thenReturn(iterationTestPlanItem);
squash.recordResult(testResult);
// check we call all necessary API methods to record the result
verify(api).createCampaign("Selenium " + testContext.getName(), "");
verify(api).createIteration(campaign, SeleniumTestsContextManager.getThreadContext().getApplicationVersion());
verify(api).addTestCaseInIteration(iteration, 1);
verify(api).setExecutionResult(iterationTestPlanItem, ExecutionStatus.BLOCKED);
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestSquashTMConnector method testDoNotRecordResult.
/**
* Test we do not record result when no testId is provided
* @param testContext
*/
@Test(groups = { "ut" })
public void testDoNotRecordResult(ITestContext testContext) {
JSONObject connect = new JSONObject();
connect.put(SquashTMConnector.TMS_SERVER_URL, "http://myServer");
connect.put(SquashTMConnector.TMS_PROJECT, "project");
connect.put(SquashTMConnector.TMS_USER, "user");
connect.put(SquashTMConnector.TMS_PASSWORD, "password");
SquashTMConnector squash = spy(new SquashTMConnector());
squash.init(connect);
doReturn(api).when(squash).getApi();
// customize test result so that it has attributes
when(testResult.getMethod()).thenReturn(testMethod);
when(testResult.isSuccess()).thenReturn(true);
when(testResult.getName()).thenReturn("MyTest");
when(testResult.getTestContext()).thenReturn(testContext);
when(testResult.getParameters()).thenReturn(new Object[] {});
when(testResult.getAttribute("testContext")).thenReturn(SeleniumTestsContextManager.getThreadContext());
when(testMethod.getAttributes()).thenReturn(new CustomAttribute[] {});
when(api.createCampaign(anyString(), anyString())).thenReturn(campaign);
when(api.createIteration(any(Campaign.class), anyString())).thenReturn(iteration);
when(api.addTestCaseInIteration(iteration, 1)).thenReturn(iterationTestPlanItem);
squash.recordResult(testResult);
// check we do not call API as testId is not provided
verify(api, never()).createCampaign("Selenium " + testContext.getName(), "");
verify(api, never()).createIteration(campaign, SeleniumTestsContextManager.getThreadContext().getApplicationVersion());
verify(api, never()).addTestCaseInIteration(iteration, 1);
verify(api, never()).setExecutionResult(iterationTestPlanItem, ExecutionStatus.SUCCESS);
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestSquashTMConnector method testNoExceptionWhenErrorInRecording.
/**
* Check that if any error occurs during result recording, it does not raise any exception, only message will be displayed
* @param testContext
*/
@Test(groups = { "ut" })
public void testNoExceptionWhenErrorInRecording(ITestContext testContext) {
JSONObject connect = new JSONObject();
connect.put(SquashTMConnector.TMS_SERVER_URL, "http://myServer");
connect.put(SquashTMConnector.TMS_PROJECT, "project");
connect.put(SquashTMConnector.TMS_USER, "user");
connect.put(SquashTMConnector.TMS_PASSWORD, "password");
SquashTMConnector squash = spy(new SquashTMConnector());
squash.init(connect);
doReturn(api).when(squash).getApi();
CustomAttribute testIdAttr = new CustomAttribute() {
@Override
public Class<? extends Annotation> annotationType() {
return null;
}
@Override
public String[] values() {
return new String[] { "1" };
}
@Override
public String name() {
return "testId";
}
};
// customize test result so that it has attributes
when(testResult.getMethod()).thenReturn(testMethod);
when(testResult.isSuccess()).thenReturn(true);
when(testResult.getName()).thenReturn("MyTest");
when(testResult.getTestContext()).thenReturn(testContext);
when(testResult.getParameters()).thenReturn(new Object[] {});
when(testResult.getAttribute("testContext")).thenReturn(SeleniumTestsContextManager.getThreadContext());
when(testMethod.getAttributes()).thenReturn(new CustomAttribute[] { testIdAttr });
when(api.createCampaign(anyString(), anyString())).thenThrow(new ScenarioException("Something went wrong"));
when(api.createIteration(any(Campaign.class), anyString())).thenReturn(iteration);
when(api.addTestCaseInIteration(iteration, 1)).thenReturn(iterationTestPlanItem);
squash.recordResult(testResult);
// check we do not call API as testId is not provided
verify(api).createCampaign("Selenium " + testContext.getName(), "");
verify(api, never()).createIteration(campaign, SeleniumTestsContextManager.getThreadContext().getApplicationVersion());
verify(api, never()).addTestCaseInIteration(iteration, 1);
verify(api, never()).setExecutionResult(iterationTestPlanItem, ExecutionStatus.SUCCESS);
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestSquashTMApi method testCreateCampaignWithFolder.
/**
* Check that folders are created when they to not exist for this project
*/
@Test(groups = { "ut" })
public void testCreateCampaignWithFolder() {
PowerMockito.when(Project.getAll()).thenReturn(Arrays.asList(project1, project2));
doReturn(Arrays.asList(campaign1, campaign2)).when(project1).getCampaigns();
PowerMockito.when(CampaignFolder.getAll()).thenReturn(Arrays.asList(campaignFolder1, campaignFolder2));
Campaign myCampaign = new Campaign("http://localhost:4321/campaigns/3", 3, "mycampaign");
PowerMockito.when(Campaign.create(project1, "mycampaign", null)).thenReturn(myCampaign);
SquashTMApi api = new SquashTMApi("http://localhost:4321", "user", "password", "project1");
Campaign newCampaign = api.createCampaign("mycampaign", "myFolder/folder1");
Assert.assertEquals(newCampaign, myCampaign);
// check campaign creation has been called
PowerMockito.verifyStatic(Campaign.class);
Campaign.create(project1, "mycampaign", null);
// check 2 folders has been created
PowerMockito.verifyStatic(CampaignFolder.class);
CampaignFolder.create(eq(project1), any(), eq("myFolder"));
PowerMockito.verifyStatic(CampaignFolder.class);
CampaignFolder.create(eq(project1), any(), eq("folder1"));
}
use of com.seleniumtests.connectors.tms.squash.entities.Campaign in project seleniumRobot by bhecquet.
the class TestProject method testGetCampaignsInProjectWithError.
@Test(groups = { "ut" }, expectedExceptions = ScenarioException.class)
public void testGetCampaignsInProjectWithError() {
GetRequest getRequest = (GetRequest) createServerMock("GET", "/projects/44/campaigns", 200, "{}", "request");
when(getRequest.asPaged(any(), (Function<HttpResponse<JsonNode>, String>) any(Function.class))).thenThrow(UnirestException.class);
Project project = new Project("http://localhost:4321/projects/44", 44, "project");
List<Campaign> campaigns = project.getCampaigns();
}
Aggregations