-
Notifications
You must be signed in to change notification settings - Fork 0
Junit5 β Repeated tests
Devrath edited this page Oct 23, 2023
·
2 revisions
@RepeatedTest(100)
fun `Add multiple products, total price sum is correct`(){
val productOne = Product(id = 1, name = "Product-1", price = 1.0)
val productTwo = Product(id = 2, name = "Product-2", price = 2.0)
cart.addProduct(productOne,1)
cart.addProduct(productTwo,1)
assertThat(cart.getTotalCost()).isEqualTo(3.0)
}
- We can use
@RepeatedTest(100)
for example to run a test 100 times or any number of times needed. - This ensures that the test is successful all the number of times.
- It is especially useful because it helps to identify the
flaky
tests. -
Flaky
tests are the tests that run sometimes and fail sometimes.