use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCause method testEqualsNullStep1.
@Test(groups = { "ut" })
public void testEqualsNullStep1() {
ErrorCause cause1 = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", null);
ErrorCause cause2 = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", new TestStep("step2", null, new ArrayList<>(), true));
Assert.assertNotEquals(cause1, cause2);
}
use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceBadMatchErrorGettingReference.
/**
* Bad match: an error occurs when getting reference snapshot
* We should not fail
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceBadMatchErrorGettingReference() 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);
// error occurs when getting reference on step 1
when(serverConnector.getReferenceSnapshot(0)).thenReturn(null);
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 TestErrorCauseFinder method testCompareStepInErrorWithReferenceNoIDForStep3.
/**
* Same thing as above but only step1 has no ID with bad match so we cannot look for previous step reference
* In this case, we get an unknown_page cause
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceNoIDForStep3() throws Exception {
step1.setStepResultId(null);
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);
// good comparison with step1 reference
when(stepReferenceComparatorStep1.compare()).thenReturn(81);
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());
}
use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceBadMatchNoPreviousStep.
/**
* Matching between reference picture stored on server and the one for current test is bad (we are not on the right page)
* No previous step can be found
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceBadMatchNoPreviousStep() throws Exception {
ITestResult testResult = Reporter.getCurrentTestResult();
TestNGResultUtils.setSeleniumRobotTestContext(testResult, SeleniumTestsContextManager.getThreadContext());
SeleniumTestsContextManager.getThreadContext().getTestStepManager().setTestSteps(Arrays.asList(stepFailed, lastStep));
// comparison successful
PowerMockito.whenNew(StepReferenceComparator.class).withArguments(new File(stepFailed.getSnapshots().get(0).getScreenshot().getFullImagePath()), referenceImgStep2).thenReturn(stepReferenceComparatorStep2);
// bad comparison with step2 reference
when(stepReferenceComparatorStep2.compare()).thenReturn(49);
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 TestErrorCauseFinder method testCompareStepInErrorWithReferenceNoStep.
/**
* Check the case where no TestStep is available
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceNoStep() throws Exception {
ITestResult testResult = Reporter.getCurrentTestResult();
TestNGResultUtils.setSeleniumRobotTestContext(testResult, SeleniumTestsContextManager.getThreadContext());
SeleniumTestsContextManager.getThreadContext().getTestStepManager().setTestSteps(new ArrayList<>());
List<ErrorCause> causes = new ErrorCauseFinder(testResult).compareStepInErrorWithReference();
Assert.assertEquals(causes.size(), 0);
Assert.assertFalse(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
Aggregations