Running Automated Test Suite

From FirebugWiki

Revision as of 13:37, 23 December 2009 by Honza (Talk | contribs)
Jump to: navigation, search

This page explains how to run Firebug automated tests. All information on this page are related to Firebug 1.5.


See also:


Contents

Prerequisities

  1. Install Firebug 1.5 (the latest version recommended)
  2. Install FBTest 1.5 (the latest version recommended)


Running Tests

  1. Use Firebug->Open Test Console menu to open test console window.
  2. Put http://getfirebug.com/tests/content/testlists/firebug1.5.html URL into the URL bar.
  3. Press Run All button on the toolbar.


That's it!

You should see how all tests displayed in the test console are executed step by step. The browser window should automatically load test pages and automate specific steps needed for test execution.

Note: The FBTest extension will be part of the Firebug 1.5X at some point (development version). This means that you need to install it only if you want to test Firebug 1.5 (end user version). This page will be updated as soon as this happens.


Test Console UI

The main purpose of the test console is displaying and executing tests in a test suite. First of all let's see a screenshot of the console. Note that all tests are divided into groups.

Fbtest-ui.png

You can see a toolbar with following actions:

  • Run All Use this button to run all tests from the current test suite.
  • Stop Use this button to stop running tests.
  • Fail Halt Use this option (two state button) to automatically stop test execution when an error occurs (you need Chromebug 1.5 installed). In such a case Chromebug will automatically switch into the debug mode showing the source line where the error happend. You can continue debugging the test code or put a breakpoint and run the test again.
  • Refresh Reloads the current test list.
  • No Timeout Use this option to disable timeout on running test. Useful when debugging in Chromebug.


There is also an URL bar that allows to load a test setup file. This file specifies all info necessary to execute the tests. Such a file is included in Firebug distribution and so, if you have Firebug installed you can always load: chrome://firebug/content/testList.html (the default Firebug test setup file).


Export Errors

In order to export all reported failures, just right-click within the Test Console window content and pick Copy All Errors from the context menu. An error report will be copied into the clipboard together with information about current Firebug & Firefox versions, current test-list URL and also version and name of the underlying OS.

Fb-test-copy-all-errors.png

Running Tests From The Command Line

It's also possible to automatically run all tests (or one specific test) from the command line when launching Firefox. The syntax of the parameter is as follows:

-runFBTests <test-setup-file-uri>#<test-driver-relative-path>

Let's see some examples.

Run all default tests afer Firefox is started using the default user profile

firefox -runFBTests chrome://firebug/content/testList.html

Run all default tests after Firefox is started using the dev user profile.

firefox -dev -runFBTests chrome://firebug/content/testList.html

Load chrome://firebug/content/testList.html test setup file and run net/1468/issue1468.js test after Firefox is started using the dev user profile.

firefox -dev -runFBTests chrome://firebug/content/testList.html#net/1468/issue1468.js


Terminology

Each automated test is typically composed two parts.

  • Test Page (*.html) This is a regular web page (often with AJAX code) that represents specific scenario being tested. Since (at least in case of Firebug tests) these pages are available online, the tester can simply load it in the browser (no need for FBTest extension), manually follow described scenario and execute the test without any automation.
  • Test Driver (*.js) This is the automation part. Piece of javascript that loads the test page and executes all steps automatically.


Finally, tests can be combined together.

  • Test List (*.html) This file is loaded into the Test Console and specifies neccessary information (URLs) about test cases and test drivers locations. It also contains a javascript inline defintion of test drivers or includes it from an external *.js file using the <script> tag.

Test List File Structure

The test list file must be implemented as a regular page. Here is an example of such a file.

<html>
<head></head>
<body>
<script type="text/javascript">
var baseURI = "https://getfirebug.com/content/";
var serverURI = "https://getfirebug.com/content/";
var testList = [
    {
        group: "Group1 Title",
        uri: "group1/testDriver1.js",
        desc: "This is a description of test 1",
        testPage: "group1/testCase1.html"
    }
];
</script>
</body>
</html>

If you load such a file into the test console, you should see one expandable group with one test.

There are following variables defined in the file.

  • baseURI Root directory with all test-drivers.
  • serverURI Root directory with all test-cases
  • testList List of tests.

Each test in the array has following properties.

  • group Name of the parent group where the test belongs to.
  • uri Relative path of the test driver
  • desc Short summary of the test (displayed in the UI)
  • testPage: relative path to the test case file.


In this particular case, both test drivers and test cases are located at https://getfirebug.com/content/ and the directory structure under this root folder would look like as follows:

<root>
    group1
        testDriver1.js
        testCase1.js
Personal tools