Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Metadata

Josh Tynjala edited this page Aug 19, 2016 · 2 revisions

[Test]

A method with [Test] metadata will be run automatically by a TestRunner.

package
{
	public class SomeTests
	{
		[Test]
		public function testSomethingImportant():void
		{
			var expectedValue:Number = 1;
			var actualValue:Number = 2 - 1;
			Assert.strictEqual(expectedValue, actualValue,
				"The values are not equal!");
		}
	}
}

The static methods defined on the nextgenas.test.assert.Assert class may be used to assert that values meet expected requirements.

[Before]

A method with [Before] metadata will be run immediately before each individual test in the same class. This method should be used to set up variables and other state required for the test before it is run.

package
{
	public class SomeTests
	{
		[Before]
		public function beforeEachTest():void
		{
			// run before testSomethingImportant()
		}

		[Test]
		public function testSomethingImportant():void
		{
			// run after beforeEachTest()
		}
	}
}

[After]

A method with [After] metadata will be run immediately after each individual test in the same class. This method may be used to clean up after a test, and it will always be called, no matter if the test passed or failed.

package
{
	public class SomeTests
	{
		[After]
		public function afterEachTest():void
		{
			// run after testSomethingImportant()
		}

		[Test]
		public function testSomethingImportant():void
		{
			// run before afterEachTest()
		}
	}
}
Clone this wiki locally