Code Monkey home page Code Monkey logo

hexunit's Introduction

hexUnit TravisCI Build Status

OOP Unit testing framework written in Haxe.

Find more information about hexMachina on hexmachina.org

Dependencies

Browser integration

alt tag

Upcoming FlashDevelop integration

alt tag

Features

  • Tests and suites are generated with annotations. No inheritance and implementation needed.
  • Asynchronous testing.
  • Solution event based. Define your own console/system to display/write your results.
  • Compatible with NodeJS for Travis integration.
  • Possibility to test only one method (For shortcut IDE integration)

List of metadatas

  • @Test
  • @Async
  • @Ignore
  • @Before
  • @After
  • @BeforeClass
  • @AfterClass
  • @Suite

Assertions provided

  • isTrue
  • isFalse
  • isNull
  • isNotNull
  • isInstanceOf
  • isNotInstanceOf
  • equals
  • deepEquals
  • arrayContains
  • notEquals
  • constructorCallThrows
  • methodCallThrows
  • setPropertyThrows

FlashDevelop integration

Macro designed for FlashDevelop to run only one unit test class or a test function (instead of a whole suit) You can download it here

How to run framework tests inside the browser

var emu = new ExMachinaUnitCore();
emu.addListener( new BrowserUnitTestNotifier( "console" ) );
emu.addTest( HexMVCSuite );
emu.addTest( HexCoreSuite );
emu.addTest( HexInjectSuite );
emu.addTest( HexMachinaSuite );
emu.addTest( HexUnitSuite );
emu.run();

How to run tests with NodeJS (you can mix tests classes with suites)

var emu = new ExMachinaUnitCore();
emu.addListener( new ConsoleNotifier(false) );
emu.addTest( InjectorTest );
emu.addTest( HexCoreSuite );
emu.run();

How to test only one method

var emu = new ExMachinaUnitCore();
emu.addListener( new BrowserUnitTestNotifier( "console" ) );
emu.addTestMethod( InjectorTest, "get_instance_errors_for_unmapped_class" );
emu.run();

Suite example (you can mix tests classes with suites)

class AsyncSuite
{
	@Suite("Async suite")
    public var list : Array<Class<Dynamic>> = [AsyncCommandSuite, AsyncCommandTest];
}

Test example

class DomainTest
{
    @Test( "Test 'name' property passed to constructor" )
    public function testConstructor() : Void
    {
        var domain = new Domain( "testConstructor" );
        Assert.equals( "testConstructor", domain.getName(), "'name' property should be the same passed to constructor" );
    }

    @Test( "Test null 'name' value passed to constructor" )
    public function testConstructorNullException() : Void
    {
        Assert.constructorCallThrows( NullPointerException, Domain, [], "" );
    }

    @Test( "Test using twice the same 'name' value" )
    public function testConstructorWithNameValues() : Void
    {
        var domain = new Domain( "testConstructorWithNameValues" );
        Assert.constructorCallThrows( IllegalArgumentException, Domain, ["testConstructorWithNameValues"], "" );
    }
}

Asynchronous test example

@Async( "Test every command was executed" )
public function testHasRunEveryCommand() : Void
{
	this._macroExecutor.add( MockAsyncCommand );
	Assert.failTrue( this._macroExecutor.hasRunEveryCommand, "'hasRunEveryCommand' should return false" );
	this._macroExecutor.executeNextCommand();
	Timer.delay( MethodRunner.asyncHandler( this._onTestHasRunEveryCommand ), 100 );
}

private function _onTestHasRunEveryCommand() : Void
{
	Assert.isTrue( this._macroExecutor.hasRunEveryCommand, "'hasRunEveryCommand' should return true" );
}

hexunit's People

Contributors

aliokan avatar chipshort avatar francisbourre avatar grosmar avatar st3vev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

aliokan chipshort

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.