Search in sources :

Example 1 with CucumberScenarioWrapper

use of com.seleniumtests.core.runner.CucumberScenarioWrapper in project seleniumRobot by bhecquet.

the class TestCucumberScenarioWrapper method testScenarioToStringShortPlaceholder.

/**
 * With placeholder on scenario outline, we use the pickle name as placeholders have been replaced
 * @param testNGCtx
 */
@Test(groups = { "ut" })
public void testScenarioToStringShortPlaceholder(ITestContext testNGCtx) {
    when(cucumberScenarioWithExample.getName()).thenReturn("short <foo>");
    Pickle pickle2 = new Pickle("short foobar", "en", new ArrayList<>(), new ArrayList<>(), // location for scenario outline
    Arrays.asList(// location for scenario outline
    new PickleLocation(2, 2), new PickleLocation(6, 5)));
    PickleEvent pickleEvent2 = new PickleEvent("uri", pickle2);
    Assert.assertEquals(new CucumberScenarioWrapper(pickleEvent2, cucumberScenarioWithExample).toString(150), "short foobar");
}
Also used : Pickle(gherkin.pickles.Pickle) PickleLocation(gherkin.pickles.PickleLocation) PickleEvent(gherkin.events.PickleEvent) CucumberScenarioWrapper(com.seleniumtests.core.runner.CucumberScenarioWrapper) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Example 2 with CucumberScenarioWrapper

use of com.seleniumtests.core.runner.CucumberScenarioWrapper in project seleniumRobot by bhecquet.

the class TestSeleniumTestContext3 method testNewOutputFolderWithOddTestName.

/**
 * Check that with a test name containing special characters, we create an
 * output folder for this test whose name is the name of the test
 *
 * @throws IllegalAccessException
 * @throws IllegalArgumentException
 * @throws NoSuchFieldException
 * @throws SecurityException
 * @throws NoSuchMethodException
 */
@Test(groups = "ut")
public void testNewOutputFolderWithOddTestName(final ITestContext testNGCtx) throws NoSuchMethodException, SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
    initThreadContext(testNGCtx);
    ITestResult testResult = GenericTest.generateResult(testNGCtx, getClass());
    CucumberScenarioWrapper scenarioWrapper = mock(CucumberScenarioWrapper.class);
    when(scenarioWrapper.toString()).thenReturn("<test | with @ chars>");
    CucumberScenarioWrapper[] params = new CucumberScenarioWrapper[] { scenarioWrapper };
    testResult.setParameters(params);
    SeleniumTestsContextManager.updateThreadContext(testResult);
    String key = testNGCtx.getSuite().getName() + "-" + testNGCtx.getName() + "-" + "com.seleniumtests.ut.core.TestSeleniumTestContext3" + "-" + "-test__with_@_chars-" + "-" + Arrays.hashCode(params);
    Assert.assertTrue(SeleniumTestsContext.getOutputFolderNames().containsKey(key));
    Assert.assertEquals(SeleniumTestsContextManager.getThreadContext().getRelativeOutputDir(), "-test__with_@_chars-");
}
Also used : ITestResult(org.testng.ITestResult) CucumberScenarioWrapper(com.seleniumtests.core.runner.CucumberScenarioWrapper) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.testng.annotations.Test) ConnectorsTest(com.seleniumtests.ConnectorsTest) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) XmlTest(org.testng.xml.XmlTest) GenericTest(com.seleniumtests.GenericTest)

Example 3 with CucumberScenarioWrapper

use of com.seleniumtests.core.runner.CucumberScenarioWrapper in project seleniumRobot by bhecquet.

the class TestCucumberScenarioWrapper method testScenarioEqualLong.

/**
 * Check the unstripped version is used to compare 2 cucumberscenariowrappers
 * @param testNGCtx
 */
@Test(groups = { "ut" })
public void testScenarioEqualLong(ITestContext testNGCtx) {
    when(cucumberScenario.getName()).thenReturn("a very long scenario outline name with some special characters like @ and |. But we should not strip it, only display a message saying its much too long.");
    when(cucumberScenario2.getName()).thenReturn("a very long scenario outline name with some special characters like @ and |. But we should not strip it, only display a message saying its much too long.2");
    Assert.assertNotEquals(new CucumberScenarioWrapper(pickleEventLong, cucumberScenario), new CucumberScenarioWrapper(pickleEventLong2, cucumberScenario2));
}
Also used : CucumberScenarioWrapper(com.seleniumtests.core.runner.CucumberScenarioWrapper) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Example 4 with CucumberScenarioWrapper

use of com.seleniumtests.core.runner.CucumberScenarioWrapper in project seleniumRobot by bhecquet.

the class TestCucumberScenarioWrapper method testScenarioToStringShortNoPlaceholder.

/**
 * Without placeholder on scenario outline, we use the scenario outline description plus example value
 * @param testNGCtx
 */
@Test(groups = { "ut" })
public void testScenarioToStringShortNoPlaceholder(ITestContext testNGCtx) {
    when(cucumberScenarioWithExample.getName()).thenReturn("short");
    Pickle pickle2 = new Pickle("short", "en", new ArrayList<>(), new ArrayList<>(), // location for scenario outline
    Arrays.asList(// location for scenario outline
    new PickleLocation(2, 2), // location for example
    new PickleLocation(6, 5)));
    PickleEvent pickleEvent2 = new PickleEvent("uri", pickle2);
    Assert.assertEquals(new CucumberScenarioWrapper(pickleEvent2, cucumberScenarioWithExample).toString(-1), "short-| bar | bar2 |");
}
Also used : Pickle(gherkin.pickles.Pickle) PickleLocation(gherkin.pickles.PickleLocation) PickleEvent(gherkin.events.PickleEvent) CucumberScenarioWrapper(com.seleniumtests.core.runner.CucumberScenarioWrapper) Test(org.testng.annotations.Test) MockitoTest(com.seleniumtests.MockitoTest)

Aggregations

CucumberScenarioWrapper (com.seleniumtests.core.runner.CucumberScenarioWrapper)4 Test (org.testng.annotations.Test)4 MockitoTest (com.seleniumtests.MockitoTest)3 PickleEvent (gherkin.events.PickleEvent)2 Pickle (gherkin.pickles.Pickle)2 PickleLocation (gherkin.pickles.PickleLocation)2 ConnectorsTest (com.seleniumtests.ConnectorsTest)1 GenericTest (com.seleniumtests.GenericTest)1 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1 ITestResult (org.testng.ITestResult)1 XmlTest (org.testng.xml.XmlTest)1