From 1020f0a5045436d4e0c1ee6ee8b7bafbbf715980 Mon Sep 17 00:00:00 2001 From: "Kirill.Safonov" Date: Wed, 17 Nov 2010 20:17:02 +0300 Subject: [PATCH] Export test results (IDEA-11707): stylesheet fixes, show ignored status --- .../export/TestResultsXmlFormatter.java | 62 ++-- .../testframework/export/intellij-export.xsl | 299 ++++++++++-------- 2 files changed, 217 insertions(+), 144 deletions(-) diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/TestResultsXmlFormatter.java b/platform/testRunner/src/com/intellij/execution/testframework/export/TestResultsXmlFormatter.java index c8418e0f942a..6038a9e54d90 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/TestResultsXmlFormatter.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/TestResultsXmlFormatter.java @@ -37,11 +37,10 @@ public class TestResultsXmlFormatter { private static final String ELEM_SUITE = "suite"; private static final String ATTR_NAME = "name"; private static final String ATTR_DURATION = "duration"; - private static final String ATTR_TOTAL = "total"; - private static final String ATTR_PASSED = "passed"; - private static final String ATTR_FAILED = "failed"; - private static final String ATTR_STATUS = "status"; + private static final String ELEM_COUNT = "count"; + private static final String ATTR_VALUE = "value"; + private static final String ATTR_STATUS = "status"; private final RuntimeConfiguration myRuntimeConfiguration; private final ContentHandler myResultHandler; private final AbstractTestProxy myTestRoot; @@ -62,24 +61,30 @@ public class TestResultsXmlFormatter { private void execute() throws SAXException { myResultHandler.startDocument(); - int total = 0; - int passed = 0; + Map counts = new HashMap(); for (AbstractTestProxy node : myTestRoot.getAllTests()) { if (!node.isLeaf()) continue; - total++; - if (node.isPassed()) passed++; + String status = getStatusString(node); + increment(counts, status); + increment(counts, "total"); } - Map attrs = new HashMap(); - attrs.put(ATTR_NAME, myRuntimeConfiguration.getName()); + Map runAttrs = new HashMap(); + runAttrs.put(ATTR_NAME, myRuntimeConfiguration.getName()); Integer duration = myTestRoot.getDuration(); if (duration != null) { - attrs.put(ATTR_DURATION, String.valueOf(duration)); + runAttrs.put(ATTR_DURATION, String.valueOf(duration)); } - attrs.put(ATTR_TOTAL, String.valueOf(total)); - attrs.put(ATTR_PASSED, String.valueOf(passed)); - attrs.put(ATTR_FAILED, String.valueOf(total - passed)); - startElement(ELEM_RUN, attrs); + startElement(ELEM_RUN, runAttrs); + + for (Map.Entry entry : counts.entrySet()) { + Map a = new HashMap(); + a.put(ATTR_NAME, entry.getKey()); + a.put(ATTR_VALUE, String.valueOf(entry.getValue())); + startElement(ELEM_COUNT, a); + endElement(ELEM_COUNT); + } + if (myTestRoot.shouldSkipRootNodeForExport()) { for (AbstractTestProxy node : myTestRoot.getChildren()) { processNode(node); @@ -92,6 +97,11 @@ public class TestResultsXmlFormatter { myResultHandler.endDocument(); } + private static void increment(Map counts, String status) { + Integer count = counts.get(status); + counts.put(status, count != null ? count + 1 : 1); + } + private void processNode(AbstractTestProxy node) throws SAXException { Map attrs = new HashMap(); attrs.put(ATTR_NAME, node.getName()); @@ -145,7 +155,7 @@ public class TestResultsXmlFormatter { } if (buffer.length() > 0) { Map a = new HashMap(); - a.put(ATTR_OUTPUT_TYPE, lastType.toString()); + a.put(ATTR_OUTPUT_TYPE, getTypeString(lastType.get())); startElement(ELEM_OUTPUT, a); writeText(buffer.toString()); endElement(ELEM_OUTPUT); @@ -160,12 +170,26 @@ public class TestResultsXmlFormatter { } private static String getTypeString(ConsoleViewContentType type) { - return type == ConsoleViewContentType.ERROR_OUTPUT ? "error" : "normal"; + return type == ConsoleViewContentType.ERROR_OUTPUT ? "stderr" : "stdout"; } private static String getStatusString(AbstractTestProxy node) { - if (node.isPassed()) return "passed"; - return "failed"; // TODO + int magnitude = node.getMagnitude(); + // TODO enumeration! + switch (magnitude) { + case 0: + return "skipped"; + case 5: + return "ignored"; + case 1: + return "passed"; + case 6: + return "failed"; + case 8: + return "error"; + default: + return node.isPassed() ? "passed" : "failed"; + } } private void startElement(String name, Map attributes) throws SAXException { diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl b/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl index fcc64f0c0428..6d234683e7fd 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/intellij-export.xsl @@ -61,6 +61,7 @@ h1 { color: #151515; font-size: 180%; + line-height: 1.1em; font-weight: bold; } @@ -88,10 +89,22 @@ color: #ff0000 } - span.success { + span.error { + color: #ff0000 + } + + span.passed { color: #1d9d01 } + span.ignored { + color: #f8d216 + } + + span.skipped { + color: #f8d216 + } + hr { background-color: blue } @@ -101,31 +114,32 @@ } #header { - padding: 1.3em 0 1em 0; + padding: 0; position: fixed; width: 100%; - height: 2em; z-index: 10; background-color: #c7ceda; } + #header h1.title { + margin-top: 1em; + margin-bottom: 0; + } + #header h1 { - margin: 0 3em 0 1.7em; + margin: 0 3em 1em 1.7em; } #header .time { - margin-right: 3em; + margin-top: 2.2em; + margin-right: 3.4em; float: right; } #treecontrol { margin: 0; - padding: 1em 3em .5em 0; - position: fixed; - top: 4em; - right: 0; + padding: .5em 3em .5em 0; text-align: right; - width: 100%; background-color: #fff; } @@ -136,7 +150,7 @@ } #content { - padding: 7em 2.5em 2em 1.7em; + padding: 0 2.5em 2em 1.7em; } #content ul { @@ -158,7 +172,7 @@ } #content ul li.level.top > span { - padding: .5em 0 .5em 1em; + padding: .5em .4em .5em 1em; font-size: 120%; color: #151515; background-color: #f2f2f2; @@ -169,6 +183,10 @@ border-left: solid 10px #f02525; } + #content ul li.level.top.ignored > span { + border-left: solid 10px #f8d216; + } + #content ul li.level.suite > span { margin-bottom: .8em; padding: 0 0 0 .8em; @@ -183,6 +201,10 @@ border-left: solid 15px #f02525; } + #content ul li.level.suite.ignored > span { + border-left: solid 15px #f8d216; + } + #content ul li.level.suite > ul { margin-bottom: 1.5em; } @@ -191,15 +213,19 @@ padding: .3em 0 .3em 1em; color: #0046b0; font-size: 100%; - border-left: solid 3px #93e078; + border-left: solid 6px #93e078; border-bottom: solid 1px #dbdbdb; } #content ul li.level.test.failed > span { - border-left: solid 3px #f02525; + border-left: solid 6px #f02525; } - #content ul li.text span { + #content ul li.level.test.ignored > span { + border-left: solid 6px #f8d216; + } + + #content ul li.text p, #content ul li.text span { margin-bottom: 1.5em; color: #151515 !important; font-size: 90% !important; @@ -210,16 +236,24 @@ border: none !important; } + #content ul li.text span { + margin-bottom: 0; + display: block; + } + + #content ul li.text span.stderr { + color: #8b0000 !important; + } + #content ul li .time { margin-right: .5em; width: 5em; text-align: right; - font-size: 90%; + font-size: 13px; color: #151515; font-style: normal; font-weight: normal; float: right; - background-color: #fff; } #content ul li span .status { @@ -235,6 +269,11 @@ #content ul li.failed > span .status { color: #ff0000; } + + #content ul li.ignored > span .status { + color: #f8d216; + } + ]]> @@ -535,19 +575,22 @@ jQuery.cookie = function(name, value, options) {
@@ -571,6 +614,108 @@ jQuery.cookie = function(name, value, options) { + + + level + + + + suite + + + top + + + + + + + + + + + + + + + +
    + +
+
+
+ + + + level test + + +
  • + + + + + + + + + +
      + + + + + + + + +
    • + + + + +
    • +
      +
    +
  • +
    + + + + + failed open + + + ignored open + + + + open + + + + + + + + + + + + + + + + + + + + + + + + + @@ -613,100 +758,4 @@ jQuery.cookie = function(name, value, options) { - - - level - - - - suite - - - top - - - - - - failed open - - - - open - - - - - - - - - - - - - - -
      - -
    -
    -
    - - - - level test - - failed open - - -
  • - - - - - - - - - -
      - - - - - - - - -
    • - - - -
    • -
      -
    -
  • -
    - - - - - - - - - - - - - - - - - - - - -