Skip to main content
Participant
September 26, 2008
Question

How to control test execution order?

  • September 26, 2008
  • 1 reply
  • 880 views
Hi,
I have a MyTestCaseClasswith X amount of test* methods in it.

I am returning a TestSuite for as follows to be run

var ts:TestSuite = new TestSuite(MyTestCaseClasswith );

How can I control the order that the test* methods in my class are executed?
This topic has been closed for replies.

1 reply

Participating Frequently
September 26, 2008
> How can I control the order that the test* methods in my class are<br />> executed?<br /><br /> In your custom TestCase class override the getTestMethodNames() <br />function. Return an Array of Strings, where each String is the name of a <br />test method you want to run. The order of the methods in the Array is the <br />order that they will be run in. See sample below. The default behavior of <br />getTestMethodNames() as defined by TestCase is to use the output of <br />describeType() looking for functions whose name begins with "test".<br /> With that said, I would highly discourage creating tests that rely <br />on a specific order of execution. Each test method should be responsible <br />for getting the environment into a specific state prior to running to <br />ensure that unintended side effects from other tests don't cause it to <br />fail for unknown reason. With larger test suites being able to run a <br />single unit test method in isolation is a great technique for debugging <br />changes which having tests that run in a specific order would complicate.<br /><br /> override public function getTestMethodNames():Array<br /> {<br /> var array:Array = new Array();<br /> array.push("testOne");<br /> array.push("testTwo");<br /> return array;<br /> }<br /><br />-- Daniel R. <danielr@neophi.com> [http://danielr.neophi.com/]