Created
June 4, 2024 09:28
-
-
Save igorstojanovski/2b23a2f6a8204e9b94e5069a10d18b41 to your computer and use it in GitHub Desktop.
Ordered Test Execution in Junit5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.igorski.tests; | |
import org.junit.jupiter.api.DisplayName; | |
import org.junit.jupiter.api.MethodOrderer; | |
import org.junit.jupiter.api.Order; | |
import org.junit.jupiter.api.Test; | |
import org.junit.jupiter.api.TestInstance; | |
import org.junit.jupiter.api.TestMethodOrder; | |
@TestMethodOrder(MethodOrderer.OrderAnnotation.class) | |
@DisplayName("User purchase with discount code flow") | |
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | |
public class OrderedExampleTest { | |
@Order(1) | |
@DisplayName("User selects a product") | |
@Test | |
void userSelectsProduct() { | |
// Test logic for selecting a product | |
} | |
@Order(2) | |
@DisplayName("User adds product to cart") | |
@Test | |
void userAddsProductToCart() { | |
// Test logic for adding product to cart | |
} | |
@Order(3) | |
@DisplayName("User applies a discount code") | |
@Test | |
void userAppliesDiscountCode() { | |
// Test logic for applying a discount code | |
} | |
@Order(4) | |
@DisplayName("User proceeds to checkout") | |
@Test | |
void userProceedsToCheckout() { | |
// Test logic for proceeding to checkout | |
} | |
@Order(5) | |
@DisplayName("User verifies the order confirmation") | |
@Test | |
void userVerifiesOrderConfirmation() { | |
// Test logic for verifying the order confirmation | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment