Skip to content

Commit

Permalink
workaround for the bad behavior of the net.masterthought.cucumber.Rep…
Browse files Browse the repository at this point in the history
…ortBuilder
  • Loading branch information
ptrthomas committed Jun 24, 2017
1 parent ceb2c7a commit c5968d1
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 23 deletions.
28 changes: 7 additions & 21 deletions karate-demo/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>net.masterthought</groupId>
<artifactId>cucumber-reporting</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>

</dependencies>

Expand All @@ -72,28 +79,7 @@
<!-- this is ignored if you use the Karate 'parallel' runner -->
<cucumber.options>--plugin junit:target/surefire-reports/cucumber-junit.xml</cucumber.options>
</systemProperties>
<!-- else the maven-cucumber-reporting plugin won't run if tests fail -->
<testFailureIgnore>true</testFailureIgnore>
</configuration>
</plugin>
<!-- optional, only if you want pretty reports -->
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>3.8.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<cucumberOutput>target/surefire-reports</cucumberOutput>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
Expand Down
24 changes: 22 additions & 2 deletions karate-demo/src/test/java/demo/DemoTestParallel.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
import com.intuit.karate.cucumber.CucumberRunner;
import com.intuit.karate.cucumber.KarateStats;
import cucumber.api.CucumberOptions;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import net.masterthought.cucumber.Configuration;
import net.masterthought.cucumber.ReportBuilder;
import org.apache.commons.io.FileUtils;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -27,8 +34,21 @@ public static void afterClass() {

@Test
public void testParallel() {
KarateStats stats = CucumberRunner.parallel(getClass(), 5, "target/surefire-reports");
assertTrue("there are scenario failures", stats.getFailCount() == 0);
String karateOutputPath = "target/surefire-reports";
KarateStats stats = CucumberRunner.parallel(getClass(), 5, karateOutputPath);
generateReport(karateOutputPath);
assertTrue("there are scenario failures", stats.getFailCount() == 0);
}

private static void generateReport(String karateOutputPath) {
Collection<File> jsonFiles = FileUtils.listFiles(new File(karateOutputPath), new String[] {"json"}, true);
List<String> jsonPaths = new ArrayList(jsonFiles.size());
for (File file : jsonFiles) {
jsonPaths.add(file.getAbsolutePath());
}
Configuration config = new Configuration(new File("target"), "demo");
ReportBuilder reportBuilder = new ReportBuilder(jsonPaths, config);
reportBuilder.generateReports();
}

}
4 changes: 4 additions & 0 deletions karate-demo/src/test/java/log4j2.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# this is only for the net.masterthought.cucumber.ReportBuilder in DemoTestParallel.java
log4j.rootLogger = INFO, CONSOLE
log4j.appender.CONSOLE = org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout = org.apache.log4j.PatternLayout

0 comments on commit c5968d1

Please sign in to comment.