JUnit test with dynamic number of tests

前端 未结 7 629
灰色年华
灰色年华 2020-11-30 18:42

In our project I have several JUnit tests that e.g. take every file from a directory and run a test on it. If I implement a testEveryFileInDirectory method in t

7条回答
  •  北海茫月
    2020-11-30 19:02

    Should be possible in JUnit 3 by inheriting from TestSuite and overriding the tests() method to list the files and for each return an instance of a subclass of TestCase that takes the filename as constructor parameter and has a test method that tests the file given in the constructor.

    In JUnit 4 it might be even easier.

提交回复
热议问题