dennis-fedco Posted March 21, 2014 Share Posted March 21, 2014 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! 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. 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
Archived
This topic is now archived and is closed to further replies.