aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java12
-rw-r--r--sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java8
-rw-r--r--sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java2
3 files changed, 14 insertions, 8 deletions
diff --git a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java
index 12f231c17e8..bd297b61172 100644
--- a/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java
+++ b/plugins/sonar-xoo-plugin/src/main/java/org/sonar/xoo/lang/TestCaseSensor.java
@@ -76,16 +76,18 @@ public class TestCaseSensor implements Sensor {
String status = split.next();
String message = split.next();
String stack = split.next();
- long duration = Long.parseLong(split.next());
- context.newTestCaseExecution()
+ String durationStr = StringUtils.trimToNull(split.next());
+ TestCaseExecution test = context.newTestCaseExecution()
.inTestFile(testFile)
.name(name)
.ofType(TestCaseExecution.Type.valueOf(type))
.status(TestCaseExecution.Status.valueOf(status))
.message(StringUtils.trimToNull(message))
- .stackTrace(StringUtils.trimToNull(stack))
- .durationInMs(duration)
- .save();
+ .stackTrace(StringUtils.trimToNull(stack));
+ if (durationStr != null) {
+ test.durationInMs(Long.parseLong(durationStr));
+ }
+ test.save();
} catch (Exception e) {
throw new IllegalStateException("Error processing line " + lineNumber + " of file " + testplanFile.getAbsolutePath(), e);
}
diff --git a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java
index 9b0bcf722db..3e31d653a69 100644
--- a/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java
+++ b/sonar-batch/src/main/java/org/sonar/batch/test/DefaultTestCaseExecutionValueCoder.java
@@ -74,13 +74,17 @@ class DefaultTestCaseExecutionValueCoder implements ValueCoder {
long duration = value.getLong();
TestCaseExecution.Type type = TestCaseExecution.Type.values()[value.getInt()];
TestCaseExecution.Status status = TestCaseExecution.Status.values()[value.getInt()];
- return new DefaultTestCaseExecution()
+ DefaultTestCaseExecution testCaseExecution = new DefaultTestCaseExecution();
+ testCaseExecution
.inTestFile(testFile)
.ofType(type)
.name(name)
- .durationInMs(duration != -1 ? duration : null)
.status(status)
.message(message)
.stackTrace(stack);
+ if (duration != -1) {
+ testCaseExecution.durationInMs(duration);
+ }
+ return testCaseExecution;
}
}
diff --git a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java
index 1261ef7166d..937e17306f5 100644
--- a/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java
+++ b/sonar-batch/src/test/java/org/sonar/batch/mediumtest/test/TestMediumTest.java
@@ -73,7 +73,7 @@ public class TestMediumTest {
File xooTestFile = new File(testDir, "sampleTest.xoo");
File xooTestPlanFile = new File(testDir, "sampleTest.xoo.testplan");
FileUtils.write(xooTestFile, "Sample test xoo\ncontent");
- FileUtils.write(xooTestPlanFile, "test1:UNIT:OK:::3\ntest2:INTEGRATION:ERROR:Assertion failure:A very long stack:12");
+ FileUtils.write(xooTestPlanFile, "test1:UNIT:OK:::\ntest2:INTEGRATION:ERROR:Assertion failure:A very long stack:12");
TaskResult result = tester.newTask()
.properties(ImmutableMap.<String, String>builder()