use of com.hribol.automation.core.execution.executor.TestScenarioFactoryImpl in project selenium_java by sergueik.
the class TestScenarioFactoryTest method canCreateScenarioFromFile.
@Test
public void canCreateScenarioFromFile() throws IOException {
String pathToTestCase = getClass().getResource("/testCase.json").getFile();
WebDriverAction pageLoadingWebDriverAction = mock(WebDriverAction.class);
ApplicationAction initialPageLoading = mock(ApplicationAction.class);
when(initialPageLoading.getWebdriverAction()).thenReturn(Optional.of(pageLoadingWebDriverAction));
ApplicationActionFactory applicationActionFactory = mock(ApplicationActionFactory.class);
when(applicationActionFactory.getInitialPageLoading()).thenReturn(initialPageLoading);
List<Map<String, String>> testCaseSteps = ConfigurationUtils.readSteps(pathToTestCase);
for (Map<String, String> testCaseStep : testCaseSteps) {
ApplicationAction domainSpecificAction = mock(ApplicationAction.class);
String something = "something";
WebDriverAction webDriverAction = mock(WebDriverAction.class);
when(webDriverAction.getName()).thenReturn(something);
when(domainSpecificAction.getWebdriverAction()).thenReturn(Optional.of(webDriverAction));
when(applicationActionFactory.create(testCaseStep)).thenReturn(domainSpecificAction);
}
TestScenarioFactory testScenarioFactory = new TestScenarioFactoryImpl();
TestScenario testScenario = testScenarioFactory.createFromFile(applicationActionFactory, pathToTestCase);
assertEquals(testCaseSteps.size() + 1, testScenario.getActions().size());
}
Aggregations