use of com.seleniumtests.core.testanalysis.ErrorCauseFinder 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.ErrorCauseFinder in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceNoIDForStep.
/**
* When step has not been stored on server, they have no ID. Check that without ID, no comparison performed, and no error is raised
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceNoIDForStep() throws Exception {
step1.setStepResultId(null);
stepFailed.setStepResultId(null);
lastStep.setStepResultId(null);
ITestResult testResult = Reporter.getCurrentTestResult();
TestNGResultUtils.setSeleniumRobotTestContext(testResult, SeleniumTestsContextManager.getThreadContext());
SeleniumTestsContextManager.getThreadContext().getTestStepManager().setTestSteps(Arrays.asList(step1, stepFailed, lastStep));
PowerMockito.whenNew(StepReferenceComparator.class).withAnyArguments().thenReturn(stepReferenceComparatorStep2);
List<ErrorCause> causes = new ErrorCauseFinder(testResult).compareStepInErrorWithReference();
// no comparison done
PowerMockito.verifyNew(StepReferenceComparator.class, never()).withArguments(any(File.class), any(File.class));
;
Assert.assertEquals(causes.size(), 0);
Assert.assertFalse(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
use of com.seleniumtests.core.testanalysis.ErrorCauseFinder in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceBadMatchNotOnPreviousStep.
/**
* Matching between reference picture stored on server and the one for current test is bad (we are not on the right page)
* Check we try to compare to reference of step1
* Comparison with step 1 is bad (we are not on previous step)
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceBadMatchNotOnPreviousStep() 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);
// good comparison with step1 reference
when(stepReferenceComparatorStep1.compare()).thenReturn(80);
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.ErrorCauseFinder in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceBadMatchPreviousStep.
/**
* Matching between reference picture stored on server and the one for current test is bad (we are not on the right page)
* Check we try to compare to reference of step1
* Comparison with step 1 is good (we are on previous step)
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceBadMatchPreviousStep() 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);
// 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.SELENIUM_ERROR);
Assert.assertEquals(causes.get(0).getDescription(), "Wrong page found, we are on the page of step 'step 1'");
Assert.assertTrue(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
use of com.seleniumtests.core.testanalysis.ErrorCauseFinder in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceNoFailedStep.
/**
* No failed step in test, no error should be returned
* @throws Exception
*/
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceNoFailedStep() throws Exception {
ITestResult testResult = Reporter.getCurrentTestResult();
TestNGResultUtils.setSeleniumRobotTestContext(testResult, SeleniumTestsContextManager.getThreadContext());
SeleniumTestsContextManager.getThreadContext().getTestStepManager().setTestSteps(Arrays.asList(step1, lastStep));
PowerMockito.whenNew(StepReferenceComparator.class).withAnyArguments().thenReturn(stepReferenceComparatorStep2);
List<ErrorCause> causes = new ErrorCauseFinder(testResult).compareStepInErrorWithReference();
// no comparison done
PowerMockito.verifyNew(StepReferenceComparator.class, never()).withArguments(any(File.class), any(File.class));
;
Assert.assertEquals(causes.size(), 0);
Assert.assertTrue(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
Aggregations