比方說,我有一個JUnit方法生成數據驅動的單元測試中的Java
public class BusinessClassTest {
private BusinessClass fixture;
@Test
public void test1() {
//the following two paths reside in the man/test/resources folder
String inputPath = "/fixtures/1/input";
String expectedPath = "/fixtures/1/expected";
validatedFixture(inputPath, expectedPath);
}
private void valiateFixture(String inputPath, String expectedPath) {
//inputData = load the input data
//feed it to a fixture
//actual = fixture.process(inputData)
//expectedData = loadExpectedData
//validate(expectedData, actualData);
}
}
現在讓我們假設我有下夾具20個文件夾。我如何遍歷文件夾和每個文件夾生成類似於
@Test
public void test{test_number}() {
//the following two paths reside in the man/test/resources folder
String inputPath = "/fixtures/{test_number}/input";
String expectedPath = "/fixtures/{test_number}/expected";
validatedFixture(inputPath, expectedPath);
}
Idlealy的方法,我想建立這個類出隨着Maven的一部分。
更新
我用速度但是生成類,不知道怎麼搞的行家代碼生成...
謝謝您花時間做到這一點...我意識到這種做法。我需要實際的方法,以便我可以註釋他們...... – hba