public
Description: Automated Javascript Testing Framework
Home | Edit | New

Home

Some basic project information about Test Monkey.

Background

There are plenty of existing Javascript based unit test frameworks and some of our design will draw from their advantages and attempt to solve some particularly interesting and new things that the existing JS unit test frameworks don’t. Our goal is to make it easy to drop in to test as much as possible on the front end UI of a web app.

Goals

We’re going to try and make it as easy as pie to unit test the front-end UI of an HTML/Javascript based application.

Philosophy of the Design

We’ve attempted to create a similar structure as JUnit from a philosophical standpoint on the object model. Test Suites can have tests and each test can have one or more assertions. You can have multiple test suites and that’s used to group one or more tests together. Test should be thought, generally, as use cases or a set of functional things that should be tested together. Assertions simply verify that the test does what you expect.

Current Dependencies

We only have one dependency (jQuery) currently and are going to attempt to minimize any external dependencies.

License

This code is licensed under the permissive open source license, Apache Public License, Version 2.0

Note, the API is unstable and we should be able to stabilize it really, really soon. :)

Simple Example


var example = 0;

testSuite("Example that has setup",
{
	setup:function()
	{
		example = 1;
		this.foo = example;
	},
	run:function()
	{
		test("make sure that our setup ran",function()
		{
			assert( example == 1 );
			assert( this.foo == example );
		});
	}
})

In the above example, the test we’re running is considered synchronous. Once the test function exists, it will be assumed that all assertions have completed.

Asynchoronous Test


testSuite("Async Test",
{
	run:function()
	{
		testAsync("test to show async unit test using ajax call",5000,function()
		{
			$.getJSON("test.js",function(json)
			{
				assert(json)
				end();
			});
		});
	}
})

In the above example, we run an asynchronous test case. The 2nd argument (optional) is the timeout for the test (if the test doesn’t call end before this time, will auto-fail the test). In the test function, we’ll fetch a JSON URL and then assert that it returned a value. Once we’re done with the test, make sure you call end. If you don’t call end before the timeout specified (default is 10s if not specified), it will auto-fail the test.

Last edited by jhaynie, Thu Oct 16 00:01:20 -0700 2008
Home | Edit | New
Versions: