MACROMEDIA FLEX 2-TESTING FLEX APPLICATIONS WITH MERCURY QUICKTEST PROFESSIONAL Bedienungsanleitung Seite 19

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 27
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 18
498Testing
nience when you’re working with a lot of test cases. Listing 23.7 shows an example of
a test-runner application.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*"
xmlns:flexunit="flexunit.flexui.*" >
<mx:Script>
<![CDATA[
import flexunit.framework.TestSuite;
private function runTests():void
{
var ts:TestSuite = new TestSuite();
ts.addTest( myTest.suite() );
testRunner.test = ts;
testRunner.startTest();
}
] ] >
</mx:Script>
<mx:Button label="Begin Tests" click="runTests()"/>
<flexunit:TestRunnerBase id="testRunner"
width="100%" height="100%" />
</mx:Application>
Now all you need to do is create the test cases.
CREATING A TEST CASE
The last piece involves scripting your test cases by creating ActionScript classes that
return a test suite containing all the necessary tests. You can make one big test suite
with many test cases, or you can make many test suites with fewer test cases—whatever
is easier for you.
In this test-runner example, you invoke a test suite called
myTest,
shown in
listing 23.8.
package {
import flexunit.framework.TestCase;
import flexunit.framework.TestSuite;
public class myTest extends TestCase {
public function myTest( methodName:String ) {
super( methodName );
}
public static function suite():TestSuite {
var ts:TestSuite = new TestSuite();
Listing 23.7 Setting up a FlexUnit test runner
Listing 23.8 myTest.as: Sample FlexUnit test suite with a number of test cases
Add FlexUnit
namespace
Import
TestSuite class
Call addTest() function as
needed to add TestSuites
Execute
tests
Add FlexUnit MXML
visual component
Seitenansicht 18
1 2 ... 14 15 16 17 18 19 20 21 22 23 24 25 26 27

Kommentare zu diesen Handbüchern

Keine Kommentare