How to write a dynamic test case

Suppose I have a test class junit:

class MyComponentTest {

  private void test (File file) {...}

  @Test public void test1 () {test ("test1.txt")}
  @Test public void test2 () {test ("test2.txt")}
  @Test public void test3 () {test ("test3.txt")}
}

The method testreads the input from fileand tests the component with the input.

What if I change MyComponentTest?

class MyComponentTest {

  private void test (File file) {...}

  @Test public void testAll () {
    for (String name: dir.list ())
      test (new File (name))
  }
}

(testAll) (test1, test2 test3), . , Runner , .

: test junit?

+3

All Articles