Search in sources :

Example 1 with TestScenarioFactoryImpl

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());
}
Also used : ApplicationAction(com.hribol.automation.core.execution.application.ApplicationAction) TestScenarioFactoryImpl(com.hribol.automation.core.execution.executor.TestScenarioFactoryImpl) ApplicationActionFactory(com.hribol.automation.core.execution.application.ApplicationActionFactory) TestScenario(com.hribol.automation.core.execution.executor.TestScenario) TestScenarioFactory(com.hribol.automation.core.execution.executor.TestScenarioFactory) Map(java.util.Map) WebDriverAction(com.hribol.automation.core.actions.WebDriverAction) Test(org.junit.Test)

Aggregations

WebDriverAction (com.hribol.automation.core.actions.WebDriverAction)1 ApplicationAction (com.hribol.automation.core.execution.application.ApplicationAction)1 ApplicationActionFactory (com.hribol.automation.core.execution.application.ApplicationActionFactory)1 TestScenario (com.hribol.automation.core.execution.executor.TestScenario)1 TestScenarioFactory (com.hribol.automation.core.execution.executor.TestScenarioFactory)1 TestScenarioFactoryImpl (com.hribol.automation.core.execution.executor.TestScenarioFactoryImpl)1 Map (java.util.Map)1 Test (org.junit.Test)1