Testing/Authoring/

From HTML WG Wiki
< Testing
Revision as of 20:47, 12 April 2013 by Kkrueger (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Authoring Tests

Metadata

We use the same format for metadata as the CSS tests:

<link rel="author" title="NAME_OF_AUTHOR" href="mailto:EMAIL OR http://CONTACT_PAGE"/>
<link rel="help" href="RELEVANT_SPEC_SECTION"/>
<meta name="flags" content="TOKENS" />
<meta name="assert" content="TEST ASSERTION"/>

Note: for script tests, one can use the properties parameter as well, such as:

test(test_function, "Sample test", {help:"http://www.example.org/TR/foo#sec1"})

Test Formats

We currently accepted in three formats (in order of preference):

Javascript tests

These report their results back automatically using javascript in the test file. Such tests typically use the testing script harness to provide a consistent API.
You need the exact following code in your source:

	<script src="/resources/testharness.js"></script>
	<script src="/resources/testharnessreport.js"></script>

For documentation, see the source code of the testing script harness.

Note that testing script harness report will generate for you a cached metadata that you should add to your test as well, such as:

<script id="metadata_cache">/*
{
  "Sample Test": {
    "help": "http://www.example.org/TR/foo#sec1"
  }
}
*/</script>

Self-describing reftests

These are used when specific visual rendering has to be tested. The test uses two files which are (typically) supposed to have identical rendering; one relying on the feature under test and one achieving the same visual result through other means. The test passes when the renderings are pixel-for-pixel identical. In order that the tests can also be run in situations where automatic comparisons of the two pages are not possible, they must have text in the page that allows a human to determine the pass condition without access to the reference. The CSS WG Wiki has more information about writing reftests.

Manual tests

These can be used as a last resort when a feature cannot be tested automatically.

Tutorials

Process for contributing

The process for submission and approval of tests is currently:

  • Write tests
  • Wait for the tests to be reviewed