parameterized-unit-test

JUnit test with dynamic number of tests

独自空忆成欢 提交于 2019-11-27 06:06:20
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 the TestCase this shows up as only one test that may fail or succeed. But I am interested in the results on each individual file. How can I write a TestCase / TestSuite such that each file shows up as a separate test e.g. in the graphical TestRunner of Eclipse? (Coding an explicit test method for each file is not an option.) Compare also the question ParameterizedTest with a name in Eclipse Testrunner . Take a look at Parameterized Tests

JUnit test with dynamic number of tests

我与影子孤独终老i 提交于 2019-11-26 11:53:07
问题 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 the TestCase this shows up as only one test that may fail or succeed. But I am interested in the results on each individual file. How can I write a TestCase / TestSuite such that each file shows up as a separate test e.g. in the graphical TestRunner of Eclipse? (Coding an explicit test method for each file is not an option.) Compare

How do you generate dynamic (parameterized) unit tests in python?

不想你离开。 提交于 2019-11-25 23:24:34
问题 I have some kind of test data and want to create a unit test for each item. My first idea was to do it like this: import unittest l = [[\"foo\", \"a\", \"a\",], [\"bar\", \"a\", \"b\"], [\"lee\", \"b\", \"b\"]] class TestSequence(unittest.TestCase): def testsample(self): for name, a,b in l: print \"test\", name self.assertEqual(a,b) if __name__ == \'__main__\': unittest.main() The downside of this is that it handles all data in one test. I would like to generate one test for each item on the