fixed Issue #12 - added workaround for steps that are missing a result section in the json.

fixed Issue #15 - fixed issue with feature filenames where feature was only 1 word long
This commit is contained in:
Kingsley Hendrickse 2012-06-06 17:13:02 +01:00
parent f909f311fb
commit 9694d0439f
9 changed files with 77 additions and 55 deletions

View File

@ -15,11 +15,10 @@
<excludeFolder url="file://$MODULE_DIR$/target/surefire" /> <excludeFolder url="file://$MODULE_DIR$/target/surefire" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" /> <excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" />
<excludeFolder url="file://$MODULE_DIR$/target/test-classes" /> <excludeFolder url="file://$MODULE_DIR$/target/test-classes" />
<excludeFolder url="file://$MODULE_DIR$/target/work" />
</content> </content>
<orderEntry type="inheritedJdk" /> <orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:1.7.1" level="project" /> <orderEntry type="library" name="Maven: com.google.code.gson:gson:2.2.1" level="project" />
<orderEntry type="library" name="Maven: maven:velocity:1.5-20060721.044818" level="project" /> <orderEntry type="library" name="Maven: maven:velocity:1.5-20060721.044818" level="project" />
<orderEntry type="library" name="Maven: ant:ant:1.6.2" level="project" /> <orderEntry type="library" name="Maven: ant:ant:1.6.2" level="project" />
<orderEntry type="library" name="Maven: commons-collections:commons-collections:3.1" level="project" /> <orderEntry type="library" name="Maven: commons-collections:commons-collections:3.1" level="project" />

View File

@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
<version>1.7.1</version> <version>2.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>maven</groupId> <groupId>maven</groupId>

View File

@ -48,7 +48,7 @@ public class CucumberReportPublisher extends Recorder {
@Override @Override
public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener)
throws InterruptedException, IOException { throws IOException, InterruptedException {
listener.getLogger().println("[CucumberReportPublisher] Compiling Cucumber Html Reports ..."); listener.getLogger().println("[CucumberReportPublisher] Compiling Cucumber Html Reports ...");

View File

@ -14,9 +14,10 @@ public class Runner {
// list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/co_cucumber.json"); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/co_cucumber.json");
// list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/ccp_cucumber.json"); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/ccp_cucumber.json");
// list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/ss_cucumber.json"); // list.add("/Users/kings/.jenkins/jobs/aaaaa/builds/15/cucumber-html-reports/ss_cucumber.json");
list.add("/Users/kings/.jenkins/jobs/cucumber-jvm/builds/7/cucumber-html-reports/cukes.json");
list.add("/Users/kings/.jenkins/jobs/cucumber-jvm/builds/7/cucumber-html-reports/cucumber.json"); list.add("/Users/kings/.jenkins/jobs/cucumber-jvm/builds/7/cucumber-html-reports/cucumber.json");
FeatureReportGenerator featureReportGenerator = new FeatureReportGenerator(list,rd,"","7","cucumber-jvm",true,true); FeatureReportGenerator featureReportGenerator = new FeatureReportGenerator(list,rd,"","7","cucumber-jvm",false,true);
featureReportGenerator.generateReports(); featureReportGenerator.generateReports();
// boolean result = featureReportGenerator.getBuildStatus(); // boolean result = featureReportGenerator.getBuildStatus();
// System.out.println("status: " + result); // System.out.println("status: " + result);

View File

@ -72,15 +72,15 @@ public class TagObject {
return Util.findStatusCount(getStatuses(), Util.Status.FAILED); return Util.findStatusCount(getStatuses(), Util.Status.FAILED);
} }
public int getNumberOfSkipped() { public int getNumberOfSkipped() {
return Util.findStatusCount(getStatuses(), Util.Status.SKIPPED); return Util.findStatusCount(getStatuses(), Util.Status.SKIPPED);
} }
public int getNumberOfPending() { public int getNumberOfPending() {
return Util.findStatusCount(getStatuses(), Util.Status.UNDEFINED); return Util.findStatusCount(getStatuses(), Util.Status.UNDEFINED);
} }
private List<Util.Status> getStatuses(){ private List<Util.Status> getStatuses() {
List<Util.Status> statuses = new ArrayList<Util.Status>(); List<Util.Status> statuses = new ArrayList<Util.Status>();
for(ScenarioTag scenarioTag : scenarios){ for(ScenarioTag scenarioTag : scenarios){

View File

@ -98,7 +98,9 @@ public class Feature {
matches.add(modified); matches.add(modified);
} }
matches = matches.subList(1, matches.size()); List<String> sublist = matches.subList(1, matches.size());
matches = (sublist.size() == 0) ? matches : sublist;
String fileName = Joiner.on("-").join(matches) + ".html"; String fileName = Joiner.on("-").join(matches) + ".html";
return fileName; return fileName;
} }
@ -119,7 +121,7 @@ public class Feature {
return Util.findStatusCount(lookUpSteps(), Util.Status.FAILED); return Util.findStatusCount(lookUpSteps(), Util.Status.FAILED);
} }
public int getNumberOfPending(){ public int getNumberOfPending() {
return Util.findStatusCount(lookUpSteps(), Util.Status.UNDEFINED); return Util.findStatusCount(lookUpSteps(), Util.Status.UNDEFINED);
} }

View File

@ -9,13 +9,14 @@ public class Step {
private String name; private String name;
private String keyword; private String keyword;
private String line;
private Result result; private Result result;
private Row[] rows; private Row[] rows;
public Step(String name, String keyword) { public Step(String name, String keyword, String line) {
this.name = name; this.name = name;
this.keyword = keyword; this.keyword = keyword;
this.line = line;
} }
public Row[] getRows() { public Row[] getRows() {
@ -33,16 +34,23 @@ public class Step {
} }
public Long getDuration() { public Long getDuration() {
return result.getDuration(); if(result == null){
return 1L;
} else {
return result.getDuration();
}
} }
private Util.Status getInternalStatus() { private Util.Status getInternalStatus() {
if(result == null){
System.out.println("[WARNING] Line " + line + " : " + "Step is missing Result: " + keyword + " : " + name);
return Util.Status.MISSING;
} else {
return Util.resultMap.get(result.getStatus()); return Util.resultMap.get(result.getStatus());
}
} }
public Util.Status getStatus() { public Util.Status getStatus() {
// return Util.resultMap.get(result.getStatus());
Util.Status status = getInternalStatus(); Util.Status status = getInternalStatus();
Util.Status result = status; Util.Status result = status;
@ -62,7 +70,6 @@ public class Step {
result = Util.Status.FAILED; result = Util.Status.FAILED;
} }
return result; return result;
} }
public String getDataTableClass() { public String getDataTableClass() {
@ -90,11 +97,22 @@ public class Step {
if (getInternalStatus() == Util.Status.UNDEFINED) { if (getInternalStatus() == Util.Status.UNDEFINED) {
errorMessage = "Mode: Not Implemented causes Failure<br/><span class=\"undefined\">This step is not yet implemented</span>"; errorMessage = "Mode: Not Implemented causes Failure<br/><span class=\"undefined\">This step is not yet implemented</span>";
} }
content = Util.result(getStatus()) + "<span class=\"step-keyword\">" + keyword + " </span><span class=\"step-name\">" + name + "</span>" + "<div class=\"step-error-message\"><pre>" + errorMessage + "</pre></div>" + Util.closeDiv(); content = Util.result(getStatus()) + "<span class=\"step-keyword\">" + keyword + " </span><span class=\"step-name\">" + name + "</span>" + "<div class=\"step-error-message\"><pre>" + formatError(errorMessage) + "</pre></div>" + Util.closeDiv();
} else if(getStatus() == Util.Status.MISSING){
String errorMessage = "<span class=\"missing\">Result was missing for this step</span>";
content = Util.result(getStatus()) + "<span class=\"step-keyword\">" + keyword + " </span><span class=\"step-name\">" + name + "</span>" + "<div class=\"step-error-message\"><pre>" + formatError(errorMessage) + "</pre></div>" + Util.closeDiv();
} else { } else {
content = Util.result(getStatus()) + "<span class=\"step-keyword\">" + keyword + " </span><span class=\"step-name\">" + name + "</span>" + Util.closeDiv(); content = Util.result(getStatus()) + "<span class=\"step-keyword\">" + keyword + " </span><span class=\"step-name\">" + name + "</span>" + Util.closeDiv();
} }
return content; return content;
} }
private String formatError(String errorMessage){
String result = errorMessage;
if(errorMessage != null || !errorMessage.isEmpty()){
result = errorMessage.replaceAll("\\\\n","<br/>");
}
return result;
}
} }

View File

@ -1,6 +1,5 @@
package net.masterthought.jenkins.json; package net.masterthought.jenkins.json;
import net.masterthought.jenkins.ScenarioTag;
import org.joda.time.Period; import org.joda.time.Period;
import org.joda.time.format.PeriodFormatter; import org.joda.time.format.PeriodFormatter;
import org.joda.time.format.PeriodFormatterBuilder; import org.joda.time.format.PeriodFormatterBuilder;
@ -41,6 +40,7 @@ public class Util {
put("failed", Util.Status.FAILED); put("failed", Util.Status.FAILED);
put("skipped", Util.Status.SKIPPED); put("skipped", Util.Status.SKIPPED);
put("undefined", Util.Status.UNDEFINED); put("undefined", Util.Status.UNDEFINED);
put("missing", Util.Status.MISSING);
}}; }};
public static String result(Status status) { public static String result(Status status) {
@ -51,14 +51,16 @@ public class Util {
result = "<div class=\"failed\">"; result = "<div class=\"failed\">";
} else if (status == Status.SKIPPED) { } else if (status == Status.SKIPPED) {
result = "<div class=\"skipped\">"; result = "<div class=\"skipped\">";
} else if (status == Status.UNDEFINED){ } else if (status == Status.UNDEFINED) {
result = "<div class=\"undefined\">"; result = "<div class=\"undefined\">";
} else if (status == Status.MISSING) {
result = "<div class=\"missing\">";
} }
return result; return result;
} }
public static enum Status { public static enum Status {
PASSED, FAILED, SKIPPED, UNDEFINED PASSED, FAILED, SKIPPED, UNDEFINED, MISSING
} }
public static <T, R> List<R> collectScenarios(Element[] list, Closure<String, Element> clo) { public static <T, R> List<R> collectScenarios(Element[] list, Closure<String, Element> clo) {
@ -91,12 +93,12 @@ public class Util {
public static int findStatusCount(List<Util.Status> statuses, Status statusToFind) { public static int findStatusCount(List<Util.Status> statuses, Status statusToFind) {
int occurrence = 0; int occurrence = 0;
for(Util.Status status : statuses){ for (Util.Status status : statuses) {
if(status == statusToFind){ if (status == statusToFind) {
occurrence++; occurrence++;
} }
} }
return occurrence; return occurrence;
} }
public static String readFileAsString(String filePath) throws java.io.IOException { public static String readFileAsString(String filePath) throws java.io.IOException {
@ -114,7 +116,7 @@ public class Util {
return new String(buffer); return new String(buffer);
} }
public static String formatDuration(Long duration){ public static String formatDuration(Long duration) {
PeriodFormatter formatter = new PeriodFormatterBuilder() PeriodFormatter formatter = new PeriodFormatterBuilder()
.appendDays() .appendDays()
.appendSuffix(" day", " days") .appendSuffix(" day", " days")
@ -131,8 +133,8 @@ public class Util {
.appendMillis() .appendMillis()
.appendSuffix(" ms", " ms") .appendSuffix(" ms", " ms")
.toFormatter(); .toFormatter();
return formatter.print(new Period(0, duration/1000000)); return formatter.print(new Period(0, duration / 1000000));
} }
} }

View File

@ -1,28 +1,28 @@
Sat May 26 08:06:54 BST 2012 [debug] AvalonLogChute initialized using file 'velocity.log' Wed Jun 06 17:10:56 BST 2012 [debug] AvalonLogChute initialized using file 'velocity.log'
Sat May 26 08:06:54 BST 2012 [trace] ******************************************************************* Wed Jun 06 17:10:56 BST 2012 [trace] *******************************************************************
Sat May 26 08:06:54 BST 2012 [debug] Starting Jakarta Velocity v1.5-SNAPSHOT (compiled: 2006-07-21 06:25:35) Wed Jun 06 17:10:56 BST 2012 [debug] Starting Jakarta Velocity v1.5-SNAPSHOT (compiled: 2006-07-21 06:25:35)
Sat May 26 08:06:54 BST 2012 [trace] RuntimeInstance initializing. Wed Jun 06 17:10:56 BST 2012 [trace] RuntimeInstance initializing.
Sat May 26 08:06:54 BST 2012 [debug] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties Wed Jun 06 17:10:56 BST 2012 [debug] Default Properties File: org/apache/velocity/runtime/defaults/velocity.properties
Sat May 26 08:06:54 BST 2012 [debug] Trying to use logger class org.apache.velocity.runtime.log.AvalonLogChute Wed Jun 06 17:10:56 BST 2012 [debug] Trying to use logger class org.apache.velocity.runtime.log.AvalonLogChute
Sat May 26 08:06:54 BST 2012 [debug] Using logger class org.apache.velocity.runtime.log.AvalonLogChute Wed Jun 06 17:10:56 BST 2012 [debug] Using logger class org.apache.velocity.runtime.log.AvalonLogChute
Sat May 26 08:06:54 BST 2012 [debug] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl) Wed Jun 06 17:10:56 BST 2012 [debug] Default ResourceManager initializing. (class org.apache.velocity.runtime.resource.ResourceManagerImpl)
Sat May 26 08:06:54 BST 2012 [debug] ResourceLoader instantiated: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader Wed Jun 06 17:10:56 BST 2012 [debug] ResourceLoader instantiated: org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
Sat May 26 08:06:54 BST 2012 [trace] ClasspathResourceLoader : initialization complete. Wed Jun 06 17:10:56 BST 2012 [trace] ClasspathResourceLoader : initialization complete.
Sat May 26 08:06:54 BST 2012 [debug] ResourceCache: initialized (class org.apache.velocity.runtime.resource.ResourceCacheImpl) Wed Jun 06 17:10:56 BST 2012 [debug] ResourceCache: initialized (class org.apache.velocity.runtime.resource.ResourceCacheImpl)
Sat May 26 08:06:54 BST 2012 [trace] Default ResourceManager initialization complete. Wed Jun 06 17:10:56 BST 2012 [trace] Default ResourceManager initialization complete.
Sat May 26 08:06:54 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Literal Wed Jun 06 17:10:56 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Literal
Sat May 26 08:06:54 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Macro Wed Jun 06 17:10:56 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Macro
Sat May 26 08:06:54 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Parse Wed Jun 06 17:10:56 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Parse
Sat May 26 08:06:54 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Include Wed Jun 06 17:10:56 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Include
Sat May 26 08:06:54 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach Wed Jun 06 17:10:56 BST 2012 [debug] Loaded System Directive: org.apache.velocity.runtime.directive.Foreach
Sat May 26 08:06:54 BST 2012 [debug] Created '20' parsers. Wed Jun 06 17:10:56 BST 2012 [debug] Created '20' parsers.
Sat May 26 08:06:54 BST 2012 [trace] Velocimacro : initialization starting. Wed Jun 06 17:10:56 BST 2012 [trace] Velocimacro : initialization starting.
Sat May 26 08:06:54 BST 2012 [debug] Velocimacro : "velocimacro.library" is not set. Trying default library: VM_global_library.vm Wed Jun 06 17:10:56 BST 2012 [debug] Velocimacro : "velocimacro.library" is not set. Trying default library: VM_global_library.vm
Sat May 26 08:06:54 BST 2012 [debug] Velocimacro : Default library not found. Wed Jun 06 17:10:56 BST 2012 [debug] Velocimacro : Default library not found.
Sat May 26 08:06:54 BST 2012 [debug] Velocimacro : allowInline = true : VMs can be defined inline in templates Wed Jun 06 17:10:56 BST 2012 [debug] Velocimacro : allowInline = true : VMs can be defined inline in templates
Sat May 26 08:06:54 BST 2012 [debug] Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions Wed Jun 06 17:10:56 BST 2012 [debug] Velocimacro : allowInlineToOverride = false : VMs defined inline may NOT replace previous VM definitions
Sat May 26 08:06:54 BST 2012 [debug] Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed. Wed Jun 06 17:10:56 BST 2012 [debug] Velocimacro : allowInlineLocal = false : VMs defined inline will be global in scope if allowed.
Sat May 26 08:06:54 BST 2012 [debug] Velocimacro : autoload off : VM system will not automatically reload global library macros Wed Jun 06 17:10:56 BST 2012 [debug] Velocimacro : autoload off : VM system will not automatically reload global library macros
Sat May 26 08:06:54 BST 2012 [trace] Velocimacro : initialization complete. Wed Jun 06 17:10:56 BST 2012 [trace] Velocimacro : initialization complete.
Sat May 26 08:06:54 BST 2012 [trace] RuntimeInstance successfully initialized. Wed Jun 06 17:10:56 BST 2012 [trace] RuntimeInstance successfully initialized.
Sat May 26 08:06:54 BST 2012 [debug] ResourceManager : found templates/tagOverview.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader Wed Jun 06 17:10:56 BST 2012 [debug] ResourceManager : found templates/tagOverview.vm with loader org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader