php - Customizing setUp in PHPUnit -


I'm looking to run a bunch of tests with an object with different parameters in the set-up function.

How can I do this? I tried to use the @Data Provider, but it does not work with set up. I quickly found out.

What I want to do here (using @dataProvider): < / P>

  / * * @ Data Provider Provider * / Function Set Up ($ name space, $ args) {$ this- & gt; Tag = new tag ($ name space, $ args); } Function provider () {return array (array ('hello', array ()), array ('world', array ())); } Function testOne () {} function testTwo () {}  

The result of this is that testOne () and testTwo () run with the namespace "Hello" with an object And

thanks, matte

if you do not meet the test There is no need to assign the SUT in the member variable of the testcase instance. Create new tag examples in the bus provider and pass them instead of the test function

  / ** * provides different test tag examples * / function tag provider () {return array (array (new tag) 'Hello', array ()), array (new tag ('world', array ())); } / * * @dataProvider Tag Provider * / function testOne (Tag $ tag) {$ this- & gt; Some ($ tag); }  

If testOne changes the exam in a way that depends on the testTwo changes, then you can do this:

/ * * @dataProvider Tag Provider * / function testOne (Tag $ tag) {$ this- & gt; Some ($ tag); Return $ tag; } / * * @Depend Teston * / function testTwo (Tag $ tag) {$ this-> Some ($ tag); }

and then testTwo will return $ tag to testOne , change any state It was done in testOne .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -