BrowserTest

BrowserTest is a Python command-line script, that 'feeds' HyperTest tests to browsers. It does so by running its own web server and booting browsers with a URL to the web server as a command-line argument, making the browsers request tests from the server. When the tests are ran, they will make the browser report back to the server, which in turn reports back to the Python script.

This makes it possible to conveniently run a set of tests (of all supported types) from the command-line, and see the results printed to stdout. Also this allows integrating your HyperTest tests into other testing applications (obviously easiest in Python applications, although interfacing with other languages should be possible, too?), making it possible to run your Python unit tests (for the back-end) and HyperTest tests in one go, with similar output to the same console.

For HTTP tests and App tests, the web server proxies the application server that hosts the to-be-tested applications.

In More Detail

When BrowserTest is fired, it loads a config file in which paths, information about what host to proxy (for HTTP and app tests), what browsers to run and what tests to run. Then it starts a simple webserver, that recognizes certain internal URLs (for serving tests and BrowserTest-specific JS and HTML) and forwards all unknown paths to the proxy webserver.

When the server runs, the script starts looping through all browsers in the configuration file and will try to boot them with a special start URL pointing to the server as a command-line argument. If the browser can't be found on the path, the next browser is tried. If it can be found, the server will feed it the tests from the configuration file, and some additional JavaScript files.

Those JavaScripts will not only make the tests get executed, but also make the browser request the next test (if any) when the current one is done, and send the results of the current one as POST body of the request. This allows the Python script (BrowserTest) to process and print the results on the command line.

Example Output

This is what running the script looks like with the default Reporter. To have different output, or for integration purposes, custom runners can be written. Note that while the script runs, a browser window is opened and navigates through the tests.

johnny@medusa:~/projects/hypertest/trunk/hypertest$ ./run_browsertest
Going to test browser: epiphany
TestEcmaUnitTestCase (testecmaunit.js, js test)
TestTestCase - testAssert: OK
TestTestCase - testAssertEquals: OK
TestTestCase - testAssertNotEquals: OK
TestTestCase - testAssertTrue: OK
TestTestCase - testAssertFalse: OK
TestTestCase - testAssertThrows: OK
TestTestCase2 - testAssert: OK
TestTestCase2 - testAssertEquals: OK
TestTestCase2 - testAssertNotEquals: OK
TestTestCase2 - testAssertTrue: OK
TestTestCase2 - testAssertFalse: OK
TestTestCase2 - testAssertThrows: OK
time spent: 8 msecs

TestHTTPUnitTestCase (testhttpunittests.js, http test)
TestHTTPUnitTestCase - test_square_root: OK
time spent: 75 msecs

TestAppTestTestCase (testapptests.js, app test)
TestAppTestTestCase - apptestdata/test_sync.html: OK
TestAppTestTestCase - apptestdata/test_async.html: OK
time spent: 439 msecs

johnny@medusa:~/projects/hypertest/trunk/hypertest$ 

Caveats

* Real browser windows are opened, so this can only run inside a desktop environment (e.g. X-Windows).

* HTTPS is not (yet) supported.

* Logging in to the web application will have to be done manually from the browser.

* Browser windows are not killed, currently they're left open with a message stating they may be closed.