Skip to content

Commit

Permalink
Merge pull request #6 from DNAlchemist/master
Browse files Browse the repository at this point in the history
Fixes for windows platform
  • Loading branch information
DNAlchemist committed Jan 9, 2017
2 parents 87fb925 + af484bf commit 6bbdbe3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/main/groovy/ru/alfalab/gradle/CucumberRunnerGenerator.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class CucumberRunnerGenerator {

public void generate() {
project.mkdir(buildDir);
new File(buildDir, "GradleTestRunner.java").withOutputStream { os ->
os << header;
features.files.sort( { file -> file.name } ).each { file -> os << generateInnerRunnerClass(file) }
os << footer;
new File(buildDir, "GradleTestRunner.java").withWriter("utf8") { writer ->
writer << header;
features.files.sort( { file -> file.name } ).each { file -> writer << generateInnerRunnerClass(file) }
writer << footer;
}
}

Expand All @@ -37,19 +37,21 @@ class CucumberRunnerGenerator {
getFeatureClass(file.absolutePath);
}

private static pathToJavaSource(String path) { path.replace("\\", "\\\\") }

private String getHeader() {"""
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
public class GradleTestRunner {
"""}

private String getFeatureClass(String featuresDir){"""
private String getFeatureClass(String featuresPath){"""
@RunWith(Cucumber.class)
@CucumberOptions (
glue = {"${glue}"},
glue = {"${pathToJavaSource(glue)}"},
format = {"pretty", "json:build/cucumber/cucumber${classNumber}.json"},
features = {"${featuresDir}"}
features = {"${pathToJavaSource(featuresPath)}"}
)
public static class GradleTestRunner${classNumber++} { }
"""}
Expand Down

0 comments on commit 6bbdbe3

Please sign in to comment.