Added test coverage annotations
authorSteve Speicher <sspeiche@gmail.com>
Sun, 20 Jul 2014 22:47:06 -0400
changeset 719 e3d3c9068612
parent 718 958507744485
child 720 d189b4e804e2
Added test coverage annotations
coverage.css
coverage.js
ldp.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coverage.css	Sun Jul 20 22:47:06 2014 -0400
@@ -0,0 +1,81 @@
+.showCoverage {
+    position: fixed;
+    top: 50px;
+    right: 20px;
+    width: auto;
+    padding: 1px 6px;
+    text-align: center;
+    border-radius:10px;
+    z-index: 999;
+    background: none repeat scroll 0% 0% #FFF;
+    border: 1px solid #CCC;
+    border-radius: 5px;
+    font-size: 75%;
+}
+
+.coverage {
+    padding: 1em;
+    margin: 1em 0em 0em;
+    border-style: solid;
+    border-width: 1px;
+}
+
+.coverage:before {
+    display: block;
+    width: 250px;
+    margin: -1.5em 0px 0.5em;
+    font-weight: bold;
+    border: 1px solid #8B0000;
+    background: none repeat scroll 0% 0% #FFF;
+    padding: 3px 1em;
+    border-style: solid;
+    border-width: 1px;
+}
+
+.automated {
+    border-color: Green;
+    background-color: #90EE90;
+}
+
+.automated:before {
+    content: "Test Coverage: Automated";
+    border: 1px solid Green;
+}
+
+.manual {
+    border-color: #8B0000;
+    background-color: #FFA54F;
+}
+
+.manual:before {
+    content: "Test Coverage: Manual";
+    border: 1px solid #8B0000;
+}
+
+.clientOnly {
+    border-color: #668B8B;
+    background-color: #F6F9ED;
+}
+
+.clientOnly:before {
+    content: "Test Coverage: Client Only";
+    border-color: #668B8B;
+}
+
+.unimplemented {
+    border-color: crimson;
+    background-color: tomato;
+}
+
+.unimplemented:before {
+    content: "Test Coverage: Unimplemented";
+    border-color: crimson;
+}
+
+.test {
+    font-size: 80%;
+    color: #404040;
+}
+
+.test:after { content: ", "; } 
+.test:last-child:after { content: ""; }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/coverage.js	Sun Jul 20 22:47:06 2014 -0400
@@ -0,0 +1,54 @@
+$(document).ready(function() {
+    function showCoverage() {
+        $.getJSON("tests/reports/ldp-earl-manifest-all.jsonld", function(manifest) {
+            $.each(manifest["@graph"], function(index, resource) {
+                var type = resource["rdf:type"];
+                if (type && "earl:TestCase" === type["@id"] && resource.seeAlso) {
+                    var id = resource.seeAlso.split("#", 2)[1];
+                    var section = $("section[id|='" + id + "']");
+                    if (section) {
+                        section.addClass("coverage");
+                        if ("ldpt:automated" === resource.testMethod) {
+                            section.addClass("automated");
+                            section.removeClass("manual");
+                            section.removeClass("notTested");
+                        } else if ("ldpt:manual" === resource.testMethod) {
+                            section.addClass("manual");
+                            section.removeClass("notTested");
+                        } else if ("ldpt:clientOnly" === resource.testMethod) {
+                            section.addClass("clientOnly");
+                        } else {
+                            section.addClass("unimplemented");
+                        }
+
+                        var reviewStatus =  resource.reviewStatus.split(":").pop();
+                        section.children().last().after($('<span></span>')
+                            .addClass('test')
+                            .append($('<a></a>', {
+                                text: resource["rdfs:label"] + " (" + reviewStatus + ")",
+                                href: resource.documentation
+                            })));
+                    }
+                }
+            });
+            loaded = true;
+        });
+    }
+
+    var checkbox = $('#showCoverage');
+    // sometimes the checkbox will be checked on page refreshed (even if no checked attr in the HTML)
+    if (checkbox.prop('checked')) {
+        showCoverage();
+    }
+
+    checkbox.click(function() {
+        var $this = $(this);
+        if ($this.is(':checked')) {
+            showCoverage();
+        } else {
+            $(".coverage").removeClass("coverage automated manual clientOnly unimplemented");
+            $(".test").remove();
+        }
+    });
+});
+
--- a/ldp.html	Sun Jul 20 22:16:26 2014 -0400
+++ b/ldp.html	Sun Jul 20 22:47:06 2014 -0400
@@ -9,6 +9,17 @@
   <head>
     <title>Linked Data Platform 1.0</title>
     <meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
+        <!-- Test coverage: The following allows the spec to be annotated with information
+         from the test suite to help with understanding the coverage of each requirement. -->
+    <link rel="stylesheet" type="text/css" media="all" href="coverage.css">
+    <style type="text/css" media="print">
+        .coverage {
+            page-break-inside: avoid;
+        }
+    </style>
+    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
+    <script src="coverage.js"></script>
+    
     <!-- 
       === NOTA BENE ===
       For the three scripts below, if your spec resides on dev.w3 you can check them
@@ -2557,6 +2568,11 @@
 <h2>Detailed history</h2>
 <!-- <blockquote><em><a href="http://www.w3.org/TR/2013/WD-ldp-20130930/">Candidate Recommendation Draft</a></em></blockquote> -->
 <ul>
+	<li>2014-07-20 - Added test coverage utility to annotate spec with test cases covering them, to be removed before publishing (SS)</li>
+</ul>
+
+<blockquote><em><a href="http://www.w3.org/TR/2014/CR-ldp-20140619">Candidate Recommendation Draft</a></em></blockquote> -->
+<ul>
 	<li>2014-06-16 - Updated examples in Prefer section to be in request/response format (SS) </li>
 	<li>2014-06-16 - Updated examples in container sections to be in request/response format (SS) </li>
 	<li>2014-06-10 - Use http-bis and Prefer RFC numbers, adjust BNF to match bis changes (JA) </li>
@@ -2772,6 +2788,10 @@
 </ul>
 <blockquote><em><a href="http://www.w3.org/Submission/2012/SUBM-ldbp-20120326/">Submission</a></em></blockquote>
 </section>
+
+  <div class="removeOnSave showCoverage">
+    <input type="checkbox" id="showCoverage"><label for="showCoverage">Show test coverage</label></input>
+  </div>
     
   </body>
 </html>