Search in sources :

Example 1 with FeatureRunner

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

the class RunnerFileContentRendererTest method deprecatedPlaceholderTest.

@Test(expected = CucablePluginException.class)
public void deprecatedPlaceholderTest() throws Exception {
    String template = "package parallel;\n" + "\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/[CUCABLE:FEATURE].feature\"},\n" + "    plugin = {\"json:target/cucumber-report/[CUCABLE:RUNNER].json\"}\n" + ")\n" + "public class [FEATURE_FILE_NAME] {\n" + "}\n";
    when(fileIO.readContentFromFile(anyString())).thenReturn(template);
    ArrayList<String> featureFileNames = new ArrayList<>();
    featureFileNames.add("featureFileName");
    FeatureRunner featureRunner = new FeatureRunner("MyClass.java", "RunnerClass", featureFileNames);
    runnerFileContentRenderer.getRenderedRunnerFileContent(featureRunner);
}
Also used : ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 2 with FeatureRunner

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

the class RunnerFileContentRendererTest method getRenderedFeatureFileContentFromTextFileTest.

@Test
public void getRenderedFeatureFileContentFromTextFileTest() throws Exception {
    String template = "package parallel;\n" + "\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/[CUCABLE:FEATURE].feature\"},\n" + "    plugin = {\"json:target/cucumber-report/[CUCABLE:RUNNER].json\"}\n" + ")\n" + "public class [CUCABLE:RUNNER] {\n" + "}\n";
    when(fileIO.readContentFromFile(anyString())).thenReturn(template);
    String expectedOutput = "package parallel;\n" + "\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/featureFileName.feature\"},\n" + "    plugin = {\"json:target/cucumber-report/RunnerClass.json\"}\n" + ")\n" + "public class RunnerClass {\n" + "}\n" + "\n" + "\n" + "// Generated by Cucable from pathToTemplate\n";
    ArrayList<String> featureFileNames = new ArrayList<>();
    featureFileNames.add("featureFileName");
    FeatureRunner featureRunner = new FeatureRunner("pathToTemplate", "RunnerClass", featureFileNames);
    String renderedRunnerFileContent = runnerFileContentRenderer.getRenderedRunnerFileContent(featureRunner);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedRunnerFileContent = renderedRunnerFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedRunnerFileContent, is(expectedOutput));
}
Also used : ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 3 with FeatureRunner

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

the class RunnerFileContentRendererTest method customParametersTest.

@Test
public void customParametersTest() throws CucablePluginException {
    String template = "Template [CUCABLE:FEATURE] [CUCABLE:CUSTOM:test1]!\n[CUCABLE:CUSTOM:test2], [CUCABLE:CUSTOM:test1]...";
    when(fileIO.readContentFromFile(anyString())).thenReturn(template);
    Map<String, String> customParameters = new HashMap<>();
    customParameters.put("test1", "testvalue1");
    customParameters.put("test2", "another value");
    ArrayList<String> featureFileNames = new ArrayList<>();
    featureFileNames.add("featureFileName");
    FeatureRunner featureRunner = new FeatureRunner("pathToTemplate", "RunnerClass", featureFileNames);
    when(propertyManager.getCustomPlaceholders()).thenReturn(customParameters);
    String renderedRunnerFileContent = runnerFileContentRenderer.getRenderedRunnerFileContent(featureRunner);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedRunnerFileContent = renderedRunnerFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedRunnerFileContent, is("Template [CUCABLE:FEATURE] testvalue1!\n" + "another value, testvalue1...\n" + "\n" + "// Generated by Cucable from pathToTemplate\n"));
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 4 with FeatureRunner

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

the class RunnerFileContentRendererTest method getRenderedFeatureFileContentFromJavaFileTest.

@Test
public void getRenderedFeatureFileContentFromJavaFileTest() throws Exception {
    String template = "package parallel;\n" + "\n" + "package some.package;\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/[CUCABLE:FEATURE].feature\"},\n" + "    plugin = {\"json:target/cucumber-report/[CUCABLE:RUNNER].json\"}\n" + ")\n" + "public class MyClass {\n" + "}\n";
    when(fileIO.readContentFromFile(anyString())).thenReturn(template);
    String expectedOutput = "\n" + "\n" + "\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/featureFileName.feature\"},\n" + "    plugin = {\"json:target/cucumber-report/RunnerClass.json\"}\n" + ")\n" + "public class RunnerClass {\n" + "}\n" + "\n" + "\n" + "// Generated by Cucable from MyClass.java\n";
    ArrayList<String> featureFileNames = new ArrayList<>();
    featureFileNames.add("featureFileName");
    FeatureRunner featureRunner = new FeatureRunner("MyClass.java", "RunnerClass", featureFileNames);
    String renderedRunnerFileContent = runnerFileContentRenderer.getRenderedRunnerFileContent(featureRunner);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedRunnerFileContent = renderedRunnerFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedRunnerFileContent, is(expectedOutput));
}
Also used : ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 5 with FeatureRunner

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

the class RunnerFileContentRendererTest method getRenderedFeatureFileContentReplaceBackslashInCommentTest.

@Test
public void getRenderedFeatureFileContentReplaceBackslashInCommentTest() throws Exception {
    String template = "package parallel;\n" + "\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/[CUCABLE:FEATURE].feature\"},\n" + "    plugin = {\"json:target/cucumber-report/[CUCABLE:RUNNER].json\"}\n" + ")\n" + "public class [CUCABLE:RUNNER] {\n" + "}\n";
    when(fileIO.readContentFromFile(anyString())).thenReturn(template);
    String expectedOutput = "package parallel;\n" + "\n" + "import cucumber.api.CucumberOptions;\n" + "\n" + "@CucumberOptions(\n" + "    monochrome = false,\n" + "    features = {\"classpath:parallel/features/featureFileName.feature\"},\n" + "    plugin = {\"json:target/cucumber-report/RunnerClass.json\"}\n" + ")\n" + "public class RunnerClass {\n" + "}\n" + "\n" + "\n" + "// Generated by Cucable from c:/unknown/path\n";
    ArrayList<String> featureFileNames = new ArrayList<>();
    featureFileNames.add("featureFileName");
    FeatureRunner featureRunner = new FeatureRunner("c:\\unknown\\path", "RunnerClass", featureFileNames);
    String renderedRunnerFileContent = runnerFileContentRenderer.getRenderedRunnerFileContent(featureRunner);
    // In a windows system, replace line separator "\r\n" with "\n".
    renderedRunnerFileContent = renderedRunnerFileContent.replaceAll("\\r\\n", "\n");
    assertThat(renderedRunnerFileContent, is(expectedOutput));
}
Also used : ArrayList(java.util.ArrayList) FeatureRunner(com.trivago.vo.FeatureRunner) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

FeatureRunner (com.trivago.vo.FeatureRunner)8 ArrayList (java.util.ArrayList)7 Test (org.junit.Test)7 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 HashMap (java.util.HashMap)1