use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestBugTrackerReporter method testIssueNotRecordedMissingProject.
@Test(groups = { "it" })
public void testIssueNotRecordedMissingProject() throws Exception {
try {
System.setProperty(SeleniumTestsContext.BUGTRACKER_TYPE, "jira");
System.setProperty(SeleniumTestsContext.BUGTRACKER_URL, "http://localhost:1234");
System.setProperty(SeleniumTestsContext.BUGTRACKER_USER, "jira");
System.setProperty(SeleniumTestsContext.BUGTRACKER_PASSWORD, "jira");
PowerMockito.whenNew(JiraConnector.class).withAnyArguments().thenThrow(new ConfigurationException(""));
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForTestManager" }, ParallelMode.METHODS, new String[] { "testInError" });
verify(jiraConnector, never()).createIssue(any(), any(), any(), any(), any(), any(), any());
} finally {
System.clearProperty(SeleniumTestsContext.BUGTRACKER_TYPE);
System.clearProperty(SeleniumTestsContext.BUGTRACKER_URL);
System.clearProperty(SeleniumTestsContext.BUGTRACKER_USER);
System.clearProperty(SeleniumTestsContext.BUGTRACKER_PASSWORD);
}
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestTestManagerReporter method testResultIsNotRecordedServerUnavailable.
@Test(groups = { "it" })
public void testResultIsNotRecordedServerUnavailable() throws Exception {
try {
System.setProperty(SeleniumTestsContext.TMS_TYPE, "squash");
System.setProperty(SeleniumTestsContext.TMS_URL, "http://localhost:1234");
System.setProperty(SeleniumTestsContext.TMS_PROJECT, "Project");
System.setProperty(SeleniumTestsContext.TMS_USER, "squash");
System.setProperty(SeleniumTestsContext.TMS_PASSWORD, "squash");
doThrow(new ConfigurationException("Cannot contact Squash TM server API")).when(squash).getApi();
executeSubTest(1, new String[] { "com.seleniumtests.it.stubclasses.StubTestClassForTestManager" }, ParallelMode.METHODS, new String[] { "testAndSubActions" });
// check no result has been recorded
verify(api, never()).setExecutionResult(eq(iterationTestPlanItem), any());
} finally {
System.clearProperty(SeleniumTestsContext.TMS_TYPE);
System.clearProperty(SeleniumTestsContext.TMS_PROJECT);
System.clearProperty(SeleniumTestsContext.TMS_URL);
System.clearProperty(SeleniumTestsContext.TMS_USER);
System.clearProperty(SeleniumTestsContext.TMS_PASSWORD);
}
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestOsUtility method testKillProcess.
@Test(groups = { "it" })
public void testKillProcess() {
if (OSUtility.isWindows()) {
OSCommand.executeCommand("calc");
WaitHelper.waitForSeconds(2);
ProcessInfo pi = osUtil.getRunningProcess("calc");
if (pi == null) {
// Windows 10
pi = osUtil.getRunningProcess("calculator");
}
if (pi == null) {
// Windows 10
pi = osUtil.getRunningProcess("Calculator");
}
if (pi == null) {
// Windows 2016
pi = osUtil.getRunningProcess("win32calc");
}
if (pi == null) {
throw new ConfigurationException("Cannot find process 'calc', 'win32calc' or 'calculator'");
}
osUtil.killProcess(pi.getPid(), true);
Assert.assertNull(osUtil.getRunningProcess("calc"));
Assert.assertNull(osUtil.getRunningProcess("calculator"));
Assert.assertNull(osUtil.getRunningProcess("Calculator"));
Assert.assertNull(osUtil.getRunningProcess("win32calc"));
}
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestSeleniumGridConnectorFactory method testWithError.
/**
* If any error occurs when getting servlet, throw an error, grid cannot be contacted
* Check also that we retry connection during N seconds (defined by retryTimeout)
* @throws UnsupportedOperationException
* @throws IOException
* @throws UnirestException
*/
@Test(groups = { "ut" }, expectedExceptions = ConfigurationException.class)
public void testWithError() throws UnsupportedOperationException, IOException, UnirestException {
when(Unirest.get(SERVER_URL + SeleniumGridConnector.CONSOLE_SERVLET)).thenReturn(gRequest);
when(gRequest.asString()).thenThrow(UnirestException.class);
LocalDateTime start = LocalDateTime.now();
try {
SeleniumGridConnectorFactory.setRetryTimeout(5);
SeleniumGridConnectorFactory.getInstances(Arrays.asList(SERVER_URL + "/wd/hub"));
} catch (ConfigurationException e) {
// check connection duration
Assert.assertTrue(LocalDateTime.now().minusSeconds(5).isAfter(start));
throw e;
} finally {
SeleniumGridConnectorFactory.setRetryTimeout(SeleniumGridConnectorFactory.DEFAULT_RETRY_TIMEOUT);
}
}
use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceErrorInComparison.
/**
* If any error occurs in comparison, continue
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceErrorInComparison() throws Exception {
ITestResult testResult = Reporter.getCurrentTestResult();
TestNGResultUtils.setSeleniumRobotTestContext(testResult, SeleniumTestsContextManager.getThreadContext());
SeleniumTestsContextManager.getThreadContext().getTestStepManager().setTestSteps(Arrays.asList(step1, stepFailed, lastStep));
// comparison successful
PowerMockito.whenNew(StepReferenceComparator.class).withArguments(new File(stepFailed.getSnapshots().get(0).getScreenshot().getFullImagePath()), referenceImgStep2).thenReturn(stepReferenceComparatorStep2);
when(stepReferenceComparatorStep2.compare()).thenThrow(new ConfigurationException("error on init"));
List<ErrorCause> causes = new ErrorCauseFinder(testResult).compareStepInErrorWithReference();
Assert.assertEquals(causes.size(), 0);
Assert.assertTrue(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
Aggregations