I'm working on test automation for shop basket module and I'm struggling with providing test data using Junit CsvSource in the 'nice way'.
So far my test looks like this
@ParameterizedTest(name = "Total quantity and price in the cart is calculated correctly for various type items")
@CsvSource({
"Ball, 3, Glasses, 5, Cable, 15, Monitor, 25, Cube, 11",
"Camera, 10, Ball, 33, Pillow, 1, Notebook, 19, Headphones, 2"
})
void quantityAndPriceIsCorrectForDifferentTypesOfProducts(String name1, String amount1,
String name2, String amount2,
String name3, String amount3,
String name4, String amount4,
String name5, String amount5) {
task1Page = new Task1Page(driver);
task1Page.open();
List<String> names = List.of(name1, name2, name3, name4, name5);
List<String> amounts = List.of(amount1, amount2, amount3, amount4, amount5);
task1Page.addItemsToBasketFromTheList(names, amounts);
task1Page.verifyQuantityOfItemsInBasketFromList(names, amounts);
task1Page.verifyTotalPriceInBasketFromList(names, amounts);
...
}
With my current implementation I'm limited to 5 item types only. And I would like to also include cases with more products. Is there any nice way to handle that case?