
502Testing
package
{
import net.digitalprimates.fluint.tests.TestCase;
public class testCase
extends net.digitalprimates.fluint.tests.TestCase
{
public function testMilesToKm():void
{
var mph:Number = 65;
var kmh:Number = speedConverter.toKmh( mph );
assertEquals( 104,kmh);
}
public function testKmToMiles():void
{
var kmh:Number =104;
var mph:Number = speedConverter.toMph( kmh );
assertEquals( 65,mph);
}
}
}
You have the test runner, which is the foundation; you have the test cases coded; and
now you just need to add the test cases to test suites.
CREATING TEST SUITES
A Fluint test suite does one simple thing: it adds all the test cases that are needed as
part of the test suite. It too is an ActionScript class.
If you look back at listing 23.10, when creating the test runner, you added a test
suite called
testSuite
:
suiteArray.push( new testSuite() );
That file looks something like listing 23.12.
package
{
import net.digitalprimates.fluint.tests.TestSuite;
public class testSuite
extends net.digitalprimates.fluint.tests.TestSuite
{
public function testSuite()
{
addTestCase( new testCase() );
}
}
}
Listing 23.11 testCase.as: Creating Fluint test cases
Listing 23.12 testSuite.as: Adding test cases to the Fluint test suite
Add all cases
to test
Add all cases
to test
Kommentare zu diesen Handbüchern