Search in sources :

Example 11 with CucableFeature

use of com.trivago.vo.CucableFeature in project cucable-plugin by trivago.

the class FeatureFileConverterTest method convertEmptyPathListToSingleScenariosAndRunnersTest.

@Test
public void convertEmptyPathListToSingleScenariosAndRunnersTest() throws Exception {
    propertyManager.setParallelizationMode(PropertyManager.ParallelizationMode.SCENARIOS.toString());
    List<CucableFeature> cucableFeatures = new ArrayList<>();
    cucableFeatures.add(new CucableFeature("", null));
    featureFileConverter.generateParallelizableFeatures(cucableFeatures);
}
Also used : ArrayList(java.util.ArrayList) CucableFeature(com.trivago.vo.CucableFeature) Test(org.junit.Test)

Example 12 with CucableFeature

use of com.trivago.vo.CucableFeature in project cucable-plugin by trivago.

the class FeatureFileConverterTest method convertToSingleScenariosAndRunnersWithScenarioNameTest.

@Test
public void convertToSingleScenariosAndRunnersWithScenarioNameTest() throws Exception {
    String generatedFeatureDir = testFolder.getRoot().getPath().concat("/features/");
    String generatedRunnerDir = testFolder.getRoot().getPath().concat("/runners/");
    String scenarioMatchText = "Feature: feature1\n Scenario: scenarioName1";
    final String FEATURE_FILE_NAME = "FEATURE_FILE.feature";
    final String GENERATED_FEATURE_FILE_NAME = "FEATURE_FILE_scenario001_run001_IT.feature";
    propertyManager.setNumberOfTestRuns(1);
    propertyManager.setGeneratedFeatureDirectory(generatedFeatureDir);
    propertyManager.setGeneratedRunnerDirectory(generatedRunnerDir);
    propertyManager.setScenarioNames("scenarioName1");
    when(fileIO.readContentFromFile(FEATURE_FILE_NAME)).thenReturn("TEST_CONTENT");
    when(fileIO.readContentFromFile(generatedFeatureDir + "/" + GENERATED_FEATURE_FILE_NAME)).thenReturn(scenarioMatchText);
    List<CucableFeature> cucableFeatures = new ArrayList<>();
    CucableFeature cucableFeature = new CucableFeature(FEATURE_FILE_NAME, null);
    cucableFeatures.add(cucableFeature);
    when(fileSystemManager.getPathsFromCucableFeature(cucableFeature)).thenReturn(Collections.singletonList(Paths.get(cucableFeature.getName())));
    List<SingleScenario> scenarioList = new ArrayList<>();
    SingleScenario singleScenario = getSingleScenario();
    scenarioList.add(singleScenario);
    when(gherkinDocumentParser.getSingleScenariosFromFeature("TEST_CONTENT", FEATURE_FILE_NAME, null)).thenReturn(scenarioList);
    when(gherkinDocumentParser.matchScenarioWithScenarioNames("en", scenarioMatchText)).thenReturn(0);
    String featureFileContent = "test";
    when(featureFileContentRenderer.getRenderedFeatureFileContent(singleScenario)).thenReturn(featureFileContent);
    when(runnerFileContentRenderer.getRenderedRunnerFileContent(any(FeatureRunner.class))).thenReturn("RUNNER_CONTENT");
    featureFileConverter.generateParallelizableFeatures(cucableFeatures);
    ArgumentCaptor<String> logCaptor = ArgumentCaptor.forClass(String.class);
    verify(logger, times(1)).info(logCaptor.capture(), any(CucableLogger.CucableLogLevel.class), any(CucableLogger.CucableLogLevel.class), any(CucableLogger.CucableLogLevel.class));
    assertThat(logCaptor.getAllValues().get(0), is("Cucable created 1 separate feature file and 1 runner."));
    verify(fileIO, times(2)).writeContentToFile(anyString(), anyString());
}
Also used : SingleScenario(com.trivago.vo.SingleScenario) ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CucableFeature(com.trivago.vo.CucableFeature) Test(org.junit.Test)

Example 13 with CucableFeature

use of com.trivago.vo.CucableFeature in project cucable-plugin by trivago.

the class FeatureFileConverterTest method convertToSingleScenariosAndMultiRunnersWithScenarioNamesAndExampleKeywordTest.

@Test
public void convertToSingleScenariosAndMultiRunnersWithScenarioNamesAndExampleKeywordTest() throws Exception {
    String generatedFeatureDir = testFolder.getRoot().getPath().concat("/features/");
    String generatedRunnerDir = testFolder.getRoot().getPath().concat("/runners/");
    final String scenarioMatch1Text = "Feature: feature1\n Scenario: scenarioName1";
    final String scenarioMatch2Text = "Feature: feature2\n Example: scenarioName2";
    final String FEATURE_FILE_NAME = "FEATURE_FILE.feature";
    final String GENERATED_FEATURE_FILE_NAME1 = "FEATURE_FILE_scenario001_run001_IT.feature";
    final String GENERATED_FEATURE_FILE_NAME2 = "FEATURE_FILE_scenario002_run001_IT.feature";
    propertyManager.setNumberOfTestRuns(1);
    propertyManager.setGeneratedFeatureDirectory(generatedFeatureDir);
    propertyManager.setGeneratedRunnerDirectory(generatedRunnerDir);
    propertyManager.setParallelizationMode("scenarios");
    propertyManager.setScenarioNames("scenarioName1, scenarioName2");
    when(fileIO.readContentFromFile(FEATURE_FILE_NAME)).thenReturn("TEST_CONTENT");
    when(fileIO.readContentFromFile(generatedFeatureDir + "/" + GENERATED_FEATURE_FILE_NAME1)).thenReturn(scenarioMatch1Text);
    when(fileIO.readContentFromFile(generatedFeatureDir + "/" + GENERATED_FEATURE_FILE_NAME2)).thenReturn(scenarioMatch2Text);
    when(fileIO.readContentFromFile(generatedFeatureDir + "/" + FEATURE_FILE_NAME)).thenReturn("TEST_CONTENT");
    List<CucableFeature> cucableFeatures = new ArrayList<>();
    CucableFeature cucableFeature = new CucableFeature(FEATURE_FILE_NAME, null);
    cucableFeatures.add(cucableFeature);
    when(fileSystemManager.getPathsFromCucableFeature(cucableFeature)).thenReturn(Collections.singletonList(Paths.get(cucableFeature.getName())));
    List<SingleScenario> scenarioList = new ArrayList<>();
    SingleScenario singleScenario = getSingleScenario();
    scenarioList.add(singleScenario);
    scenarioList.add(singleScenario);
    when(gherkinDocumentParser.getSingleScenariosFromFeature("TEST_CONTENT", FEATURE_FILE_NAME, null)).thenReturn(scenarioList);
    when(gherkinDocumentParser.matchScenarioWithScenarioNames("en", scenarioMatch1Text)).thenReturn(0);
    when(gherkinDocumentParser.matchScenarioWithScenarioNames("en", scenarioMatch2Text)).thenReturn(1);
    String featureFileContent = "test";
    when(featureFileContentRenderer.getRenderedFeatureFileContent(singleScenario)).thenReturn(featureFileContent);
    when(runnerFileContentRenderer.getRenderedRunnerFileContent(any(FeatureRunner.class))).thenReturn("RUNNER_CONTENT");
    featureFileConverter.generateParallelizableFeatures(cucableFeatures);
    ArgumentCaptor<String> logCaptor = ArgumentCaptor.forClass(String.class);
    verify(logger, times(1)).info(logCaptor.capture(), any(CucableLogger.CucableLogLevel.class), any(CucableLogger.CucableLogLevel.class), any(CucableLogger.CucableLogLevel.class));
    assertThat(logCaptor.getAllValues().get(0), is("Cucable created 2 separate feature files and 2 runners."));
    verify(fileIO, times(4)).writeContentToFile(anyString(), anyString());
}
Also used : SingleScenario(com.trivago.vo.SingleScenario) ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CucableFeature(com.trivago.vo.CucableFeature) Test(org.junit.Test)

Example 14 with CucableFeature

use of com.trivago.vo.CucableFeature in project cucable-plugin by trivago.

the class FileSystemManagerTest method getPathsFromCucableFeatureFullPathTest.

@Test
public void getPathsFromCucableFeatureFullPathTest() throws CucablePluginException {
    CucableFeature cucableFeatures = new CucableFeature("src/test/resources", null);
    List<Path> pathsFromCucableFeature = fileSystemManager.getPathsFromCucableFeature(cucableFeatures);
    assertThat(pathsFromCucableFeature, is(notNullValue()));
    assertThat(pathsFromCucableFeature.size(), is(2));
}
Also used : Path(java.nio.file.Path) CucableFeature(com.trivago.vo.CucableFeature) Test(org.junit.Test)

Example 15 with CucableFeature

use of com.trivago.vo.CucableFeature in project cucable-plugin by trivago.

the class FileSystemManagerTest method getPathsFromCucableFeatureValidFeatureTest.

@Test
public void getPathsFromCucableFeatureValidFeatureTest() throws CucablePluginException {
    CucableFeature cucableFeatures = new CucableFeature("src/test/resources/feature1.feature", null);
    List<Path> pathsFromCucableFeature = fileSystemManager.getPathsFromCucableFeature(cucableFeatures);
    assertThat(pathsFromCucableFeature, is(notNullValue()));
    assertThat(pathsFromCucableFeature.size(), is(1));
}
Also used : Path(java.nio.file.Path) CucableFeature(com.trivago.vo.CucableFeature) Test(org.junit.Test)

Aggregations

CucableFeature (com.trivago.vo.CucableFeature)17 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)12 FeatureRunner (com.trivago.vo.FeatureRunner)8 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)8 SingleScenario (com.trivago.vo.SingleScenario)7 Path (java.nio.file.Path)4 CucableLogLevel (com.trivago.logging.CucableLogger.CucableLogLevel)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1