I’m looking to run a bunch of tests with one object with different parameters in the setUp function.
How do I do this? I tried using the @dataProvider, but that doesn’t work with setUp I quickly found out..
Here’s what I’d like to do (using @dataProvider):
/*
* @dataProvider provider
*/
function setUp($namespace, $args) {
$this->tag = new Tag($namespace, $args);
}
function provider() {
return array(
array('hello', array()),
array('world', array())
);
}
function testOne() {
}
function testTwo() {
}
The result is that testOne() and testTwo() are run against an object with the namespace “hello” and an object with the namespace “world”
Any help would be greatly appreciated!
Thanks,
Matt
You don’t have to assign the SUT to a member variable of the TestCase instance if it does not suit the test. Simply create new Tag instances in the provider and pass them to the test function instead
If
testOnealters the test in a way thattestTwodepends on the changes, you can do:And then
testTwowill use the returned$tagfromtestOne, along with any state changes made to it intestOne.