]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5338 Add stacktrace when test_data measure is used
authorJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 16 Jul 2014 10:28:22 +0000 (12:28 +0200)
committerJulien Lancelot <julien.lancelot@sonarsource.com>
Wed, 16 Jul 2014 11:03:24 +0000 (13:03 +0200)
server/sonar-server/src/test/resources/org/sonar/server/test/ws/TestsShowActionTest/show_from_test_data.json
sonar-server/src/main/java/org/sonar/server/test/ws/TestsShowAction.java
sonar-server/src/test/java/org/sonar/server/test/ws/TestsShowActionTest.java

index f8832a0f01f695be499c98e92a4bc620eaac9e18..97a9239999b6902d2e1847e1a2673e1387faff06 100644 (file)
@@ -1,18 +1,16 @@
 {
-"tests": [
+  "tests": [
     {
       "name": "test1",
       "status": "OK",
-      "durationInMs": 10,
-      "coveredLines": 32
+      "durationInMs": 10
     },
     {
       "name": "test2",
       "status": "ERROR",
       "durationInMs": 97,
-      "coveredLines": 21,
       "message": "expected:<true> but was:<false>",
-      "stackTrace" : "java.lang.AssertionError: expected:<true> but was:<false>\n\tat org.junit.Assert.fail(Assert.java:91)\n\tat org.junit.Assert.failNotEquals(Assert.java:645)\n\tat org.junit.Assert.assertEquals(Assert.java:126)\n\tat org.junit.Assert.assertEquals(Assert.java:145)\n"
+      "stackTrace": "java.lang.AssertionError: expected:<true> but was:<false>\n\tat org.junit.Assert.fail(Assert.java:91)\n\tat org.junit.Assert.failNotEquals(Assert.java:645)\n\tat org.junit.Assert.assertEquals(Assert.java:126)\n\tat org.junit.Assert.assertEquals(Assert.java:145)\n"
     }
   ]
 }
index 117a3b25c54588db6147861a3bde7c59bfd62738..ca756649a807b36eaecccb9722a0ffc5c64d43a0 100644 (file)
@@ -117,16 +117,12 @@ public class TestsShowAction implements RequestHandler {
 
         json.prop("name", cursor.getAttrValue("name"));
         json.prop("status", cursor.getAttrValue("status").toUpperCase());
-        json.prop("durationInMs", cursor.getAttrValue("time"));
+        json.prop("durationInMs", Long.parseLong(cursor.getAttrValue("time")));
 
         SMInputCursor errorCursor = cursor.childElementCursor();
         if (errorCursor.getNext() != null) {
           json.prop("message", errorCursor.getAttrValue("message"));
-
-          SMInputCursor stackTraceCursor = cursor.childElementCursor();
-          if (stackTraceCursor.getNext() != null) {
-//            json.prop("stackTrace", stackTraceCursor.getAttrValue(""));
-          }
+          json.prop("stackTrace", errorCursor.getElemStringValue());
         }
 
         json.endObject();
index 07f9be4ab61c69eefd3c496a462c2232191170b3..10f685adeded7e7bd587e58c88200120c541b6ce 100644 (file)
@@ -114,8 +114,6 @@ public class TestsShowActionTest {
         "</testcase>" +
         "</tests-details>"));
 
-    // TODO failure
-
     WsTester.TestRequest request = tester.newGetRequest("api/tests", "show").setParam("key", TEST_PLAN_KEY);
 
     request.execute().assertJson(getClass(), "show_from_test_data.json");