Sobes.tech
Junior — Middle

Kas saaksite nimetada JUnitis testide korraldamiseks kasutatavaid võtmeannotatsioone?

sobes.tech AI

Vastus AI-lt

In JUnit, the following key annotations are used to organize tests:

  • @Test — marks a method as a test.
  • @BeforeEach — method that runs before each test (initialization).
  • @AfterEach — method that runs after each test (cleanup).
  • @BeforeAll — method that runs once before all tests in the class (static).
  • @AfterAll — method that runs once after all tests in the class (static).
  • @Disabled — disables the test so it does not run.

These annotations help structure tests, manage setup and cleanup of the environment for each test or the entire test set.