Hi All,
I have been trying to write a theory test for my component but doesnt
seem to get it working, is there something wrong that i am doing while
writing the theory case, would write the process that i am following,
before that would like to ask if i can write after and before test
methods in the testclass along with the datapoint(data for the theory)
and the theory method, this becomes necessary in cases where i need to
innitialize my comments with some values n then apply a theortical
test on my component.
the process i follow is as follows -
1. create a seprate testCase - TestMyComp.as
package sampleSuite.tests
{
import flexunit.framework.Assert;
public class TestMyComp
{
private var myComp:MyComp;
public function TestMyComp()
{
super();
}
[Before]
public function beforeFun():void {
myComp= new myComp();
myComp.max = 100;
myComp.min = 100;
}
[After]
public function afterFun():void {
myComp= null;
}
[DataPoints]
[ArrayElementType("int")]
public static function provideData():Array {
var arr:Array = new Array();
for(var i:int = myComp.min;i<myComp.max;i++)
{
arr.push(i);
}
return arr;
}
[Theory]
public function testMyTheory( value1:int ):void {
var val1:Number = fun1( value1);//function fun1 does
some mathematical operation
var val2:Number = fun2( val1 );//function fun2 does
some mathematical operation
//in my case val1 and val2 should always be equal,thats what am trying
to test using the thery
Assert.assertEquals( val1,val2 );
}
}
2.
package sampleSuite
{
import sampleSuite.tests.*;
[Suite]
[RunWith("org.flexunit.experimental.theories.Theories")]
public class SampleSuite {
public var t2:TestMyComp;
}
3.
Add the test suite to the testRunner.mxml:
flexUnitCore.run( SampleSuite );
when i run the test runner, the theory class fails to initialize and i
get two errors.
Thanks
Saurabh