Skip to content

Unit Test ‐ Basic test structure

Devrath edited this page Oct 23, 2023 · 1 revision

Annotations

  • @Test -> Used to indicate that the function is a test case.
  • @BeforeEach -> This will ensure it will run every time before each of the test cases is run
  • @AfterEach -> This will ensure it will run every time after each of the test cases is run

Code

class ExampleUnitTest {

    @BeforeEach
    fun setUp(){ }

    @AfterEach
    fun tearDown(){ }

    @Test
    fun addition_isCorrect() {
        assertThat(2+2).isEqualTo(4)
    }
    
}