Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
test:scripttest [2012/06/14 14:22] – better indentation fantasaitest:scripttest [2012/12/11 18:19] – [Per-Test Metadata] plinss
Line 24: Line 24:
  
 <code html> <code html>
-<script src="/resources/testharness.js"></script> +<script type="text/javascript" src="/resources/testharness.js"></script> 
-<script src="/resources/testharnessreport.js"></script>+<script type="text/javascript" src="/resources/testharnessreport.js"></script>
 </code> </code>
   * Each test can have one or more asserts. Note: some prefer a test is limited to a single assert but that is not mandatory.   * Each test can have one or more asserts. Note: some prefer a test is limited to a single assert but that is not mandatory.
Line 32: Line 32:
   * A test fails at the first failing assert, and the remainder of the test is (typically) not run.   * A test fails at the first failing assert, and the remainder of the test is (typically) not run.
   * If the file containing the tests is a HTML file with an element of id "log", this will be populated with a table containing the test results after all the tests have run.   * If the file containing the tests is a HTML file with an element of id "log", this will be populated with a table containing the test results after all the tests have run.
 +
 +===== Writing tests =====
 +
 +The full API of testharness.js is documented within the [[http://w3c-test.org/resources/testharness.js|file]] itself. [[http://documentup.com/paulirish/testharness.js|The API is also documented here]].
 +
 ==== Bug Reporting ==== ==== Bug Reporting ====
  
Line 38: Line 43:
 ==== Per-Test Metadata ==== ==== Per-Test Metadata ====
  
-Additionally, test-specific metadata can be passed in the properties. These are used when the individual test has different metadata from that stored in the <head>. The recognized metadata properties are:+Test-specific metadata can be passed in the properties object to the test constructor. These are used when an individual test has different metadata from that stored in the <head>. The recognized metadata properties are:
  
   * help - The url for the part of the specification being tested   * help - The url for the part of the specification being tested
Line 51: Line 56:
      { help: 'http://www.w3.org/TR/spec#section',       { help: 'http://www.w3.org/TR/spec#section', 
        assert: ['This tests something.', 'This also tests something else.'],        assert: ['This tests something.', 'This also tests something else.'],
-       author: 'John Doe <john@doe.com>' }+       author: ['John Doe <john@doe.com>', 'Jane Doe http://example.com/doe/jane'}
 ); );
 </code> </code>
  
-These values would override any metadata set in the <head> of the test and are only needed when the individual test's metadata is different from what's in the <head>.+Each value can be either a single string, or an array of strings if multiple values need to be specified. These values would override any metadata set in the <head> of the test and are only needed when the individual test's metadata is different from what's in the <head>
 + 
 +If there is only a single script test in a file, all metadata should be in the <head> rather than the test constructor.  
 + 
 +=== Metadata Cache  === 
 + 
 +The metadata cache exposes the names of the script tests and all associated per-test metadata to our testing tool suite. Using this data we can track the testing coverage of each specification as well as generate testing statistics and reports. If there are multiple script tests in a file, the metadata cache must be present, even if there is no test-specific metadata present (to list the names of each script test). 
 + 
 +The version of testharnessreport.js on http://test.csswg.org/resources now contains code that reads your per-test metadata and compares it to the cached version stored in the <head>. If the cache is not present, or is out of sync, it'll display a message to that effect and generate a link which, when clicked, will generate the appropriate source code for the cached metadata suitable for copy/paste into the test's <head>. The metadata cache need only be generated once just before submitting a test to suites that care about metadata, and regenerated only when the metadata changes.
  
-If there is only a single script test in a file, all metadata should be in the <head>.+To access this functionality, launch your script test in a browser and follow the link that appears at the top of the page.
 
test/scripttest.txt · Last modified: 2014/12/09 15:48 by 127.0.0.1
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki