Name

Test.Run.Harness - Abstract base class for test harness

SYNOPSIS

        var Harness
        var isNode        = typeof process != 'undefined' && process.pid

        if (isNode) {
            require('Task/Test/Run/NodeJSBundle')

            Harness = Test.Run.Harness.NodeJS
        } else 
            Harness = Test.Run.Harness.Browser.ExtJS


        var INC = (isNode ? require.paths : []).concat('../lib', '/jsan')


        Harness.configure({
            title     : 'Sample.Dist Test Suite',

            preload : [
                "jsan:Task.Joose.Core",
                "jsan:Task.JooseX.Namespace.Depended.Auto",
                {
                    text : "use.paths = " + Harness.prepareINC(INC)
                }
            ]
        })


        Harness.start(
            '010_sanity.t.js',

            // advanced descriptors for test files
            {
                url     : '020_basic.t.js',

                // replace `preload` option of harness
                preload : [
                    "jsan:Task.Joose.Stable",
                ]
            },
            {
                url     : '030_advanced.t.js',

                // append to `preload` option of harness
                alsoPreload : [
                    "jsan:Task.Joose.Stable",
                ],

                scopeProvider  : 'Scope.Provider.Window' // or just 'Window'
            }

        )

DESCRIPTION

Test.Run.Harness is an abstract base harness class in Test.Run hierarchy. This class provides no UI, you should use one of it subclasses, for example [Test.Run.Harness.Browser.ExtJS]

USAGE

Methods

configure

void configure(Object options)

This method configure the harness instance. It just copies the passed configuration option into static instance.

options - configuration options (values of attributes for this class, see below for details)

start

void start(String url1, String url2, ...)

This method starts a whole test suite

url1, url2, ... - the variable number of test files urls or, in general case, test files descriptors. Descriptor is an object with the following structure:

        {
            url         : 'test_file_url.t.js',

            preload     : [], // when given - will replace the `preload` option of harness
            alsoPreload : [], // when given - will append to the `preload` option of harness

            scopeProvider   : 'IFrame'  // 'IFrame' is default for Web and 'NodeJS' for server-side
                                        // contains a name of the Scope.Provider class, with which 
                                        // the scope of the test will be created 
        }

See also Scope-Provider

Configuration options

title

String title

The title of the test suite

passThroughEx

Boolean passThroughEx

The sign whether the each tests in suite should re-throw any exceptions caught (sometimes useful for debugging with FireBug). Defaults to 'false'.

transparentEx

Boolean transparentEx

The sign whether the each tests in suite shouldn't catch any exceptions at all. Exceptions will be thrown "as is". This is also useful for debugging. Defaults to 'false'

keepResults

Boolean keepResults

The sign whether the results of the tests should not be immediately released. Under results here means the final state of the test scope, which may be represented with iframe or browser window.

preload

Array preload

The array which contains the information about which files should be preloaded into each test's scope. The following rules applies during processing of the array:

  1. If the string entry represent a class name (for example : Test.Run.Test) it is converting to the url, like "../lib/Test/Run/Test.js"

  2. All string entries starting with 'jsan:' are replaced with the link to corresponding JSAN module. For example:

            jsan:Task.Joose.Core
  1. If the entry ends with ".js", its supposed to be the url and is passing without modifications.

  2. If the entry is an Object with text property, then the value of that property will be evaluted in the test's global scope directly. In this way you can run arbitrary code for setup.

runCore

String runCore

Either parallel or sequential. Indicates how the individual tests should be run - several at once or one-by-one.

maxThreads

Number maxThreads

The maximum number of tests running at the same time. Only applicable for parallel run-core.

testClass

Class testClass

The test class which will be used for running tests, defaults to Test.Run.Test.

SEE ALSO

General documentation for Joose: http://joose.github.com/Joose/

BUGS

All complex software has bugs lurking in it, and this module is no exception.

Please report any bugs through the web interface at http://github.com/SamuraiJack/test.run/issues

AUTHORS

Nickolay Platonov nplatonov@cpan.org

COPYRIGHT AND LICENSE

Copyright (c) 2010, Nickolay Platonov

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.