Search in sources :

Example 41 with ErrorCause

use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.

the class TestErrorCauseFinder method testCompareStepInErrorWithReferenceNoIDForStep2.

/**
 * Same thing as above but only the failed step has no ID
 * In this case, we consider comparison has been performed because other steps have IDs
 * @throws Exception
 */
@Test(groups = { "ut" })
public void testCompareStepInErrorWithReferenceNoIDForStep2() throws Exception {
    stepFailed.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.assertTrue(TestNGResultUtils.isErrorCauseSearchedInReferencePicture(testResult));
}
Also used : ErrorCauseFinder(com.seleniumtests.core.testanalysis.ErrorCauseFinder) ITestResult(org.testng.ITestResult) ErrorCause(com.seleniumtests.core.testanalysis.ErrorCause) StepReferenceComparator(com.seleniumtests.util.imaging.StepReferenceComparator) File(java.io.File) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) GenericTest(com.seleniumtests.GenericTest) MockitoTest(com.seleniumtests.MockitoTest)

Example 42 with ErrorCause

use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.

the class TestErrorCause method testToStringWithRootCauseNoDetails2.

@Test(groups = { "ut" })
public void testToStringWithRootCauseNoDetails2() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true, RootCause.DEPENDENCIES, null, 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");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ErrorCause(com.seleniumtests.core.testanalysis.ErrorCause) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 43 with ErrorCause

use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.

the class TestErrorCause method testToStringWithRootCauseAndDetails2.

/**
 * If error type is "UNKNOWN_PAGE", check RootCause is displayed
 */
@Test(groups = { "ut" })
public void testToStringWithRootCauseAndDetails2() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true, RootCause.DEPENDENCIES, "Error from system X", false);
    step.setFailed(true);
    String desc = new ErrorCause(ErrorType.UNKNOWN_PAGE, "some changes", step).toString();
    Assert.assertEquals(desc, "This page has never been encountered: some changes on step 'step1'\n" + "Declared root Cause: DEPENDENCIES => Error from system X");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ErrorCause(com.seleniumtests.core.testanalysis.ErrorCause) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 44 with ErrorCause

use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.

the class TestErrorCause method testToStringWithRootCauseAndDetails3.

/**
 * If error type is "APPLICATION_CHANGED", check RootCause is not displayed
 */
@Test(groups = { "ut" })
public void testToStringWithRootCauseAndDetails3() {
    TestStep step = new TestStep("step1", null, new ArrayList<>(), true, RootCause.DEPENDENCIES, "Error from system X", false);
    step.setFailed(true);
    String desc = new ErrorCause(ErrorType.APPLICATION_CHANGED, "some changes", step).toString();
    Assert.assertEquals(desc, "The application has been modified: some changes on step 'step1'");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ErrorCause(com.seleniumtests.core.testanalysis.ErrorCause) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 45 with ErrorCause

use of com.seleniumtests.core.testanalysis.ErrorCause in project seleniumRobot by bhecquet.

the class TestErrorCause method testToStringNoDescrition.

@Test(groups = { "ut" })
public void testToStringNoDescrition() {
    String desc = new ErrorCause(ErrorType.APPLICATION_CHANGED, null, new TestStep("step1", null, new ArrayList<>(), true)).toString();
    Assert.assertEquals(desc, "The application has been modified on step 'step1'");
}
Also used : TestStep(com.seleniumtests.reporter.logger.TestStep) ErrorCause(com.seleniumtests.core.testanalysis.ErrorCause) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

ErrorCause (com.seleniumtests.core.testanalysis.ErrorCause)49 GenericTest (com.seleniumtests.GenericTest)48 Test (org.testng.annotations.Test)48 ErrorCauseFinder (com.seleniumtests.core.testanalysis.ErrorCauseFinder)28 ITestResult (org.testng.ITestResult)28 MockitoTest (com.seleniumtests.MockitoTest)27 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)27 File (java.io.File)25 TestStep (com.seleniumtests.reporter.logger.TestStep)18 ArrayList (java.util.ArrayList)16 Field (com.seleniumtests.connectors.selenium.fielddetector.Field)8 Label (com.seleniumtests.connectors.selenium.fielddetector.Label)8 StepReferenceComparator (com.seleniumtests.util.imaging.StepReferenceComparator)8 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)3 Color (java.awt.Color)2 BufferedImage (java.awt.image.BufferedImage)2 SeleniumRobotServerException (com.seleniumtests.customexception.SeleniumRobotServerException)1