Middle
Describe the main JUnit annotations that you use
sobes.tech AI
Answer from AI
Main JUnit annotations that are frequently used:
@Test— marks a method as a test.@BeforeEach— a method that runs before each test, usually for setting up the environment.@AfterEach— a method that runs after each test, for cleaning up resources.@BeforeAll— a method that runs once before all tests in the class (must be static).@AfterAll— a method that runs once after all tests (also static).@Disabled— disables a test to temporarily not run it.
Example:
@BeforeEach
void setup() {
// prepare data
}
@Test
void testSomething() {
// test code
}
@AfterEach
void cleanup() {
// cleanup
}