Avoid multiple test

3 views
Skip to first unread message

Costin

unread,
Oct 20, 2010, 5:08:14 AM10/20/10
to Flexunit Contributors
Is there a way to avoid test duplication in this case:
I have to test an async search operation based on some input. I was
wondering if is there any functionality helping me to avoid defining
the same test for various parameters. I have now
// test search by id
[Test(async, timeout="10000")]
public function queryItemsTest():void
{

createRequest(SEARCH);
var criteria:Criteria = new SearchCriteria;
criteria.id = 100264;
_chRequest.param[CRITERIA]=criteria
callRemoteAction(resultAssertHandler);
}

// test by name

[Test(async, timeout="10000")]
public function queryItemsTestName():void
{

createRequest(SEARCH);
var criteria:Criteria = new SearchCriteria;
criteria.name= "name";
_chRequest.param[CRITERIA]=criteria
callRemoteAction(resultAssertHandler);
}

Is there a way to solve that? somthing like a stub in mockolate.
Thanks

David Wolever

unread,
Oct 20, 2010, 1:20:48 PM10/20/10
to flexunit-c...@googlegroups.com
Yup — check out FlexUnit 4's test parameterized tests:
http://docs.flexunit.org/index.php?title=Parameterized_Test_Styles#TestNG_Style

public var criterion:Array = [
[ "id", 100264 ],
["name", "name"],
];

[Test(async,dataProvider="criterion")]
public function testQueryItems(field:String, value:*):void {
... criteria[field] = value; ...

Costin Aldea

unread,
Oct 20, 2010, 1:57:27 PM10/20/10
to flexunit-c...@googlegroups.com
Thanks a lot David! I will. I was really helpful

2010/10/20 David Wolever <woleve...@gmail.com>:

--
P R O U D L I N U X U S E R
Sustain free open-source community
Free as in free speech!

Reply all
Reply to author
Forward
0 new messages