I have Implemented a test cases to check the Input and expected Json files are same.
@BeforeAll
static void setUp() throws IOException {
inputList = readInput(CommonTestConstants.FilePath + "/Input1.json");
expectedList = readExpected(CommonTestConstants.FilePath + "/Expected1.json");
assertEquals("Checking size of both list",
inputList.size(), expectedList.size());
}
static Stream<Arguments> Arguments() {
return IntStream.range(0, inputList.size())
.mapToObj(i -> Arguments.of(inputList.get(i), expectedList.get(i)));
}
@ParameterizedTest
@DisplayName("Parameterized Test For First Input")
@MethodSource("Arguments")
void testFact(Object object, ExpectedObject expected) throws Exception {
Outcome outcome = processExpectedJson(object);
assertEquals(expected, outcome);
}
For passing the different file names, I have created new test classes and test methods similar like above. It's working as expected. For better configuration now I planned to achieve it in single class. By passing input and expected Json different files dynamically like Input2.json Expected2.json from the single class.
I need to pass each file names as a parameter to BeforeAll method(Like looping), similar to a parameterized test.
Any one can advise to achieve this?