Haxe、MassiveUnit(munit)のアサーションとアノテーション

Haxe、MassiveUnit(munit)のアサーションとアノテーション

アサーション

詳しくは MassiveUnit/Assert.hx at master · massiveinteractive/MassiveUnit

それぞれ最終引数にhaxe.PosInfosをとることができるが省略。

is, isNot

Assert.isTrue(value);
Assert.isFalse(value);

Assert.isNull(value);
Assert.isNotNull(value);

Assert.isNaN(value);
Assert.isNotNaN(value);
Assert.isType(value, type);
Assert.isNotType(value, type);

are, areNot

// If the expected value is an Enum then Type.enumEq will be used to compare the two values.
Assert.areEqual(expected, actual);
Assert.areNotEqual(expected, actual);

// expected == actual
Assert.areSame(expected, actual);
Assert.areNotSame(expected, actual);

自分で落とす

// throw new AssertionException(msg, info);
Assert.fail(msg);

アノテーション

詳しくは Working with test classes · massiveinteractive/MassiveUnit Wiki

Test

@Test
public function testExample():Void {}

Async

import massive.munit.util.Timer;
@AsyncTest
public function testAsyncExample(asyncFactory:AsyncFactory):Void {
  var handler:Dynamic = asyncFactory.createHandler(this, function(){
    Assert.isFalse(false);
  }, 300);

  Timer.delay(handler, 200);
}

Skip

@Ignore("reason") @Test
public function testExample():Void {}

Setup

Once per test class

@BeforeClass
public function beforeClass():Void {}

@AfterClass
public function afterClass():Void {}

Before/After every test

@Before
public function setup():Void {}

@After
public function tearDown():Void {}