Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Testing

dan sinclair edited this page Sep 18, 2014 · 9 revisions

Overview of testing in trace-viewer.

Introduction

Trace viewer has a simple, optionally asynchronous, testing framework. The bulk of the framework exists in tvcm/unittest.html with the assertions in tvcm/unittest/assertions.html.

Test files exist in <filename>_test.html files where, typically, filename will match the name of the file being tested. The tests sit in the same folder as their respective files.

Test Creation

The general structure of tests is (assuming a file of ui/foo_test.html):

<link rel="import" href="/ui/foo.html">
<script>
'use strict';

tvcm.unittest.testSuite(function() {
  test('instantiate', function() {
    var myFoo = ui.Foo();
    this.addHTMLOutput(myFoo);
  });

  test('somethingElse', function() {
  });
});

Generally, there is one test suite per file (there is an assumption inside the code that this is true).

If you add something to the DOM with appendChild you should remove it. The exception is if you use this.addHTMLOutput(element). If you use that, then you should be good, the content will get shown if there is an error, otherwise it's hidden.

The current tests follow the convention that if the test is there just to draw things, to name them with a prefix of instantiate. So, instantiate, instantiate_multiRow, etc.

Execution

Running all tests

localhost:8003/tests.html

Running an individual test suite (such as ui/foo_test.js)

localhost:8003/test.html?testSuiteName=ui.foo

Running tests named blah

localhost:8003/test.html?testFilterString=blah

Options

If you select the small format option on the main test page and reload then the test output will be condensed to a lot smaller, making it easier to see errors without having to scroll the screen.

Clone this wiki locally