NekoUnit

NekoUnit is unit test module for Neko Programming Language.

Installation

Unpack to your favorite catalog and compile sources. You should get three files: test-case.n, test-test-case.n and utils.n.

$ tar jxf nekounit-x.x.tar.bz2
$ cd nekounit
$ nekoc *.neko

Run tests.

$ neko test-test-case.n

Testing TestTestCase
Found test-case: testFailed
Found test-case: testPassed
Found test-case: testIncomplete
Found test-case: testBroken

F.IE

Broken tests: testBroken 

testBroken
[[test-case.neko,72],[test-test-case.neko,39]]


Failed tests: testFailed 

testFailed
[[test-case.neko,72],[test-test-case.neko,35]]


Incomplete tests: testIncomplete 


Total Tests: 4, Passed: 1, Failed: 1, Broken: 1, Incomplete: 1

NekoUnit Usage Example

NekoUnit is very simple framework. It copies concept from PHPUnit2 framework.

  • Each unit test object should be inherited from TestCase prototype.
  • Each method named from "test" is test case which will be invoked and executed by unit test object.
  • Each unit test object has method setUp() which may be used to make special actions before test case will be executed. setUp() method is called before each test case.
  • class = $loader.loadmodule("utils", $loader).class;
    TestCase = $loader.loadmodule("test-case", $loader).TestCase;
    
    TestTestCase = class(TestCase);
    
    TestTestCase.getClassName = function () {
    	return "TestTestCase";
    }
    
    TestTestCase.setUp = function () {
    	$print("Preparing for testing...\n");
    }
    
    // define some test cases
    
    TestTestCase.testPassed = function () {
    	this.assertTrue(true);
    }
    
    TestTestCase.testIncomplete = function () {
    }
    
    TestTestCase.testFailed = function () {
    	this.assertTrue(false);
    }
    
    TestTestCase.testBroken = function () {
    	$throw(null);
    }
    
    @TestTestCase = function () {
    	return $new(TestTestCase).init();
    }
    
    // run tests
    
    var t = @TestTestCase();
    t.run();
    
    

    That's all, folks. Enjoy the power of Neko!

    Download

    Current version is 0.1. It is "stable", I use it in my development process everyday.
    Download from here nekounit-0.1.tar.bz2 (1.5 KBytes)

    Useful links

    Neko & Neko Virtual Machine
    PHP vs Neko (in Russian)
    Magellano PHP Application Framework

    Contact the Author

    Feel free to contact me via Neko Mailing List or ICQ: 75008864.