Class('Test.Run.Harness', {
my : {
have : {
testClass : Test.Run.Test,
tests : null,
testsByURL : null,
passThroughEx : false,
urls : null,
testsGiven : 0
},
after : {
initialize : function () {
this.testsByURL = {}
this.tests = []
this.urls = {}
}
},
methods : {
getTest : function (url) {
return this.testsByURL[url]
},
testUpdate : function (test, result) {
},
testFail : function (test, exception) {
},
testStart : function (test) {
},
testEnd : function (test) {
if (!this.isRunning()) this.testSuiteEnd()
},
testSuiteEnd : function () {
},
configure : function (config) {
Joose.O.copy(config, this)
},
startTest : function (func, testClass, topScope) {
var test = new (testClass || this.testClass)({
harness : this,
run : func,
topScope : topScope,
passThroughEx : this.passThroughEx
})
this.recordTest(test)
test.start()
},
removeTest : function (test) {
delete this.testsByURL[test.url]
this.tests = Joose.A.remove(this.tests, test)
},
reRunTest : function (test) {
this.removeTest(test)
},
reRunSuite : function () {
Joose.A.each(this.tests, function (test) {
this.reRunTest(test)
}, this)
},
recordTest : function (test) {
this.tests.push(test)
this.testsByURL[test.url] = test
},
start : function () {
this.testSuiteStart()
this.testsGiven = arguments.length
Joose.A.each(arguments, function (url) {
this.processUrl(url)
}, this)
this.testSuiteProcessed()
},
testSuiteStart : function () {
Test.Run.my.configure({
harness : this
})
},
testSuiteProcessed : function () {
},
processUrl : function (url) {
this.urls[url] = {}
},
isPassed : function () {
var res = true
Joose.A.each(this.tests, function (test) {
if (!test.isPassed()) res = false
})
return res
},
isRunning : function () {
if (this.testsGiven != this.tests.length) return true
var res = false
Joose.A.each(this.tests, function (test) {
if (!test.execEnd) res = true
})
return res
}
}
}
//eof my
})
//eof Test.Run.Harness
/**
Name
====
Test.Run.Harness - Abstract base class for test harness
SYNOPSIS
========
Test.Run.Harness.Browser.Multi.my.configure({
title : 'Module.Stub Test Suite',
passThroughEx : true,
preload : [
'/jsan/Task/Joose/Core.js',
"/jsan/JooseX/SimpleRequest.js",
'/jsan/Task/JooseX/Namespace/Depended/Web.js',
{
text : "JooseX.Namespace.Depended.Manager.my.INC = " + Ext.encode(INC)
}
]
})
Test.Run.Harness.Browser.Multi.my.start(
'010_sanity.t.js',
'020_basics.t.js'
)
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.Multi]
This class is a pure static class - it defines only static properties. Please refer to [Joose.Manual.Static](http://openjsan.org/go?l=Joose.Manual.Static)
ISA
===
[Joose.Meta.Object](http://openjsan.org/go?l=Joose.Meta.Object)
DOES
====
None
USAGE
=====
This section describes the end-user interface of this class.
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
Configuration options
---------------------
### passThroughEx
> `Boolean passThroughEx`
> The sign whether the each test in suite should re-throw any exceptions caught (useful for debugging with FireBug). Defaults to 'false'.
If set to true, exceptions will not be displayed with UI, and should be traced manually.
ATTRIBUTES
==========
This information is intended mostly for authoring Test.Run extensions, and not for end-users.
### testClass
> `Class testClass`
> The test class which will be used for running tests, defaults to [Test.Run.Test].
### tests
> `Test.Run.Test[] tests`
> The array of all test instances in harness.
### testsByURL
> `Test.Run.Test{} testsByURL`
> The hash of all test instances in harness, keyed by [url] attribute.
### urls
> `Object urls`
> Hash of test files, keyed by url. Also contain arbitrary helper info about the tests.
### testsGiven
> `Number testsGiven`
> The number of test files, given in 'start'
METHODS
=======
This information is intended mostly for authoring Test.Run extensions, and not for end-users.
### testUpdate
> `void testUpdate(Test.Run.Test test, Test.Run.Result result)`
> This method is called by the individual tests (instances of [Test.Run.Test]), each time the it has been updated (new result appeared in results queue).
The harness is supposed to provide some UI representation of the update.
> **test** - The test instance which has been updated
> **result** - The results instance which just has been added to the results queue of test
### testFail
> `void testFail(Test.Run.Test test, Object exception)`
> This method is called by the individual test (instances of [Test.Run.Test]), each time it has been failed (the exception was thrown).
The harness is supposed to provide some UI representation of this event.
> **test** - The test instance which has been failed
> **exception** - The exception thrown
### testStart
> `void testStart(Test.Run.Test test)`
> This method is called by the individual test (instances of [Test.Run.Test]), each time the test in the test suite has been started.
The harness is supposed to provide some UI representation of this event.
> **test** - The test instance which has been failed
### testEnd
> `void testEnd(Test.Run.Test test)`
> This method is called by the individual test (instances of [Test.Run.Test]), each time the test in the test suite has been finished execution.
The harness is supposed to provide some UI representation of this event.
> **test** - The test instance which has been finished
### testSuiteStart
> `void testSuiteStart()`
> This method is called when the whole test suite has been started
### testSuiteEnd
> `void testSuiteEnd()`
> This method is called when the whole test suite has been finished
### testSuiteProcessed
> `void testSuiteProcessed()`
> This method is called when the whole test suite was processed. Note that at this point some tests may still running. See also [testSuiteEnd]
### startTest
> `void startTest(Function func, Class? testClass, Object topScope)`
> This method starts the execution of a single test file.
> **func** - The function, which contain test statements. The instance of test will be passed to it as 1st argument
> **testClass** - The class which should be used for instantiation of test (defaults to value of 'testClass' attribute)
> **topScope** - The top scope in which this test was declared. This arguments is very important, because it allows the test to correctly catch the exceptions.
### recordTest
> `void recordTest(Test.Run.Test test)`
> This method records a test into internal structures of harness.
> **test** - The test instance being recorded
### removeTest
> `void removeTest(Test.Run.Test test)`
> This method removes the test from harness. All necesery cleanup should be done here.
> **test** - The test instance being removed
### reRunTest
> `void reRunTest(Test.Run.Test test)`
> This method re-runs a single test from harness. Note - passed test instance will be removed and re-created.
> **test** - The test instance being re-ran
### reRunSuite
> `void reRunSuite()`
> This method re-runs a whole test suite.
### processUrl
> `void processUrl(String url)`
> This method process a single test file url (it should create the global scope for it and launch the code)
> **test** - The test file url
### isPassed
> `Boolean isPassed()`
> This method return 'true' if all tests in test suite were passed succefully, 'false' otherwise
### isRunning
> `Boolean isRunning()`
> This method return 'true' if there is any test in test suite which is still running, 'false' otherwise
SEE ALSO
========
General documentation for Joose: [http://openjsan.org/go/?l=Joose](http://openjsan.org/go/?l=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/Module-Stub/issues](http://github.com/SamuraiJack/Module-Stub/issues)
AUTHORS
=======
Nickolay Platonov [nplatonov@cpan.org](mailto:nplatonov@cpan.org)
COPYRIGHT AND LICENSE
=====================
Copyright (c) 2009, 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:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of Nickolay Platonov nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
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.
[Test.Run.Harness.Browser.Multi]: Harness/Browser/Multi.html
[Test.Run.Test]: Test.html
*/