My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
JasUnit  
A slim unit testing framework for JavaScript
Updated Feb 4, 2010 by Luke.Sch...@gmail.com

Introduction

JasUnit is a slim unit testing framework for JavaScript, following the general design principles of xUnit.

Details

For testing your code, JasUnit allows you to:

  • Create test fixtures with any number of test methods
  • Implement setup() and teardown() methods which are run before and after each test
  • Specify a namespace for a fixture for easy organisation of tests
  • Use the default or custom logger (default appends results to a given element)
  • Use assertions from any scope - this isn't necessary or even really advised, but some people prefer it.

Examples

The following are some examples on how you might use JasUnit.

JasUnit.setup({
    logger: new JasUnit.DefaultLogger("output"),
    pushAssertionsToGlobal: true // optional.
});

JasUnit.runTests({
    namespace: "Tests.Sample",
    testOne: function() { Assert.isTrue( false ); }
});

// assertIsTrue is global because of 'pushAssertionsToGlobal'
JasUnit.runTests({
    namespace: "Tests.Sample",
    testOne: function() { assertIsTrue.isTrue( false ); }
});

// we can explicitly use the assertion scope (not really recommended)
with(JasUnit.assertScope)
{
    JasUnit.runTests({
        namespace: "Tests.Sample",
        testOne: function() { assertIsTrue.isTrue( false ); }
    });
}

Sign in to add a comment
Powered by Google Project Hosting