PHPUnit @dataProvider simply doesn't work

前端 未结 8 1746
后悔当初
后悔当初 2021-02-01 16:04

I\'ve read the documentation on the topic, and my code follows all requirements of a data provider implementation. First of all, here\'s the full code of the test just in case i

相关标签:
8条回答
  • 2021-02-01 16:37

    Hello to anyone still getting here from google :) I'm using PHP 7.0.5 and PHPUnit 5.3.2.

    As @hubro mentions - don't use __construct() as it breaks some PHPUnit annotations. Here is a SO tread with more details.

    My test's class, MyStuffTest, extends MyFancyTestcase which extends PHPUnit_Framework_TestCase. MyFancyTestcase used __construct() and I got the same error. It should use setupBeforeClass() instead to setup static data shared among all test cases - db connection and such, no need for __construct(). DataProvider works now.

    0 讨论(0)
  • 2021-02-01 16:46

    For me only removing the constructor has worked. Calling the parent constructor inside my class test broke the annotations as well even with the latest stable version of PHPUnit (6.0.9).

    I just moved the code I had on __constructor to the setUp function that is called before my unit tests run.

    0 讨论(0)
提交回复
热议问题