use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceBadMatchErrorGettingReference2.
/**
* Bad match: an exception occurs when getting reference snapshot
* We should not fail
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceBadMatchErrorGettingReference2() 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);
PowerMockito.whenNew(StepReferenceComparator.class).withArguments(new File(stepFailed.getSnapshots().get(0).getScreenshot().getFullImagePath()), referenceImgStep1).thenReturn(stepReferenceComparatorStep1);
// bad comparison with step2 reference
when(stepReferenceComparatorStep2.compare()).thenReturn(49);
// exception occurs when getting reference on step 1
when(serverConnector.getReferenceSnapshot(0)).thenThrow(new ConfigurationException(""));
List<ErrorCause> causes = new ErrorCauseFinder(testResult).compareStepInErrorWithReference();
Assert.assertEquals(causes.size(), 1);
Assert.assertEquals(causes.get(0).getType(), ErrorType.UNKNOWN_PAGE);
Assert.assertNull(causes.get(0).getDescription());
Assert.assertTrue(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCause method testEqualsNullStep3.
@Test(groups = { "ut" })
public void testEqualsNullStep3() {
ErrorCause cause1 = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", null);
ErrorCause cause2 = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", null);
Assert.assertEquals(cause1, cause2);
}
use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCause method testEqualsDifferentDescription.
@Test(groups = { "ut" })
public void testEqualsDifferentDescription() {
ErrorCause cause1 = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", new TestStep("step1", null, new ArrayList<>(), true));
ErrorCause cause2 = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes2", new TestStep("step1", null, new ArrayList<>(), true));
Assert.assertNotEquals(cause1, cause2);
}
use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCause method testToString.
@Test(groups = { "ut" })
public void testToString() {
String desc = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", new TestStep("step1", null, new ArrayList<>(), true)).toString();
Assert.assertEquals(desc, "The application has been modified: some changes on step 'step1'");
}
use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCause method testToStringWithRootCauseNoDetails.
@Test(groups = { "ut" })
public void testToStringWithRootCauseNoDetails() {
TestStep step = new TestStep("step1", null, new ArrayList<>(), true, RootCause.DEPENDENCIES, "", false);
step.setFailed(true);
String desc = new ErrorCause(ErrorType.ERROR_MESSAGE, "some changes", step).toString();
Assert.assertEquals(desc, "Error message displayed: some changes on step 'step1'\n" + "Declared root Cause: DEPENDENCIES");
}
Aggregations