dennis-fedco Posted March 21, 2014 Share Posted March 21, 2014 (edited) I want to write a test for a complex legacy code function called load(); It loads various products from different product lines, so it can have many different actual parameters and number of parameters being used by it. It has an if/then/else/if else/if else/etc. inside of it, and depending on the product, it uses almost completely different product logic. I can call testLoad() inside of my PHPUnit test, but which product do I test? well, maybe I can do testLoadProduct1(), testLoadProduct2(), testLoadProduct3(), etc. Is that the recommended way to do it, or is there better way? In a sense I need to call the same method with vastly different parameters, and the test object will be producing vastly different results every time. I figure that with the way I proposed, if anything breaks, it will be immediately clear which methods (products) actually failed the tests, which should give me a clear idea what needs to be fixed or changed. So maybe my approach is the best. Still, just starting out with phpunit, I wanted to ask here to double-check. Thanks! Edited March 21, 2014 by dennis-fedco Quote Link to comment https://forums.phpfreaks.com/topic/287155-phpunit-how-to-structure-my-test-functions-that-test-same-sut-with-different-parameters-every-time/ Share on other sites More sharing options...
trq Posted March 21, 2014 Share Posted March 21, 2014 I would just use a single test and a @dataProvider. Quote Link to comment https://forums.phpfreaks.com/topic/287155-phpunit-how-to-structure-my-test-functions-that-test-same-sut-with-different-parameters-every-time/#findComment-1473494 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.