Junior — Middle
What annotations have you used when creating automated tests?
sobes.tech AI
Answer from AI
The following annotations are often used in automated testing:
@Test— marks a method as a test.@Beforeand@BeforeEach— methods that run before each test to prepare the environment.@Afterand@AfterEach— methods that run after each test for cleanup.@BeforeClassand@BeforeAll— run once before all tests in the class.@AfterClassand@AfterAll— run once after all tests.@Ignore— skips the test.- In Android UI tests,
@RunWith(AndroidJUnit4.class)is often used to specify the test runner.
Example in JUnit 4:
@RunWith(AndroidJUnit4.class)
public class ExampleTest {
@Before
public void setUp() {
// setup code
}
@Test
public void testSomething() {
// test code
}
@After
public void tearDown() {
// cleanup code
}
}