use of com.seleniumtests.customexception.ConfigurationException in project seleniumRobot by bhecquet.
the class TestErrorCauseFinder method testSearchInLastStepErrorMessageWithException.
/**
* Check error is only logged when something goes wrong while analyzing picture
* @throws Exception
*/
@Test(groups = { "ut" })
public void testSearchInLastStepErrorMessageWithException() throws Exception {
ITestResult testResult = Reporter.getCurrentTestResult();
TestNGResultUtils.setSeleniumRobotTestContext(testResult, SeleniumTestsContextManager.getThreadContext());
SeleniumTestsContextManager.getThreadContext().getTestStepManager().setTestSteps(Arrays.asList(step1, lastStep));
PowerMockito.whenNew(ImageFieldDetector.class).withArguments(new File(lastStep.getSnapshots().get(0).getScreenshot().getFullImagePath()), (double) 1, FieldType.ERROR_MESSAGES_AND_FIELDS).thenReturn(imageFieldDetector);
List<Label> labels = new ArrayList<>();
labels.add(new Label(0, 100, 20, 50, "il y a eu un gros problème"));
labels.add(new Label(0, 100, 100, 120, "some error"));
List<Field> fields = new ArrayList<>();
fields.add(new Field(0, 100, 0, 20, "", "field"));
fields.add(new Field(0, 100, 200, 220, "", "field"));
when(imageFieldDetector.detectFields()).thenThrow(new ConfigurationException("error"));
when(imageFieldDetector.detectLabels()).thenReturn(labels);
List<ErrorCause> causes = new ErrorCauseFinder(testResult).findErrorInLastStepSnapshots();
Assert.assertEquals(causes.size(), 0);
Assert.assertTrue(TestNGResultUtils.isErrorCauseSearchedInLastStep(testResult));
}
Aggregations