AfterTest
Marks a function to be invoked after each test.
Only class member functions should be annotated with AfterTest, the annotated function should not accept any parameters and its return type has to be Unit.
Applying AfterTest to top-level, extension, or object member functions, functions accepting any parameters or functions with a return type other than Unit may lead to compilation or runtime errors, and behavior may vary on different targets.
import kotlin.test.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.*
public class UiTest {
@BeforeTest
public fun setUp() {
Dispatchers.setMain(StandardTestDispatcher)
}
@AfterTest
public fun tearDown() {
Dispatchers.resetMain()
}
@Test
public fun uiTest() { /* ... */}
}Since Kotlin
1.0Marks a function to be invoked after each test.
Only class member functions should be annotated with AfterTest, the annotated function should not accept any parameters and its return type has to be Unit.
Applying AfterTest to top-level, extension, or object member functions, functions accepting any parameters or functions with a return type other than Unit may lead to compilation or runtime errors, and behavior may vary on different targets.
import kotlin.test.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.*
public class UiTest {
@BeforeTest
public fun setUp() {
Dispatchers.setMain(StandardTestDispatcher)
}
@AfterTest
public fun tearDown() {
Dispatchers.resetMain()
}
@Test
public fun uiTest() { /* ... */}
}Since Kotlin
1.1Since Kotlin
1.0Marks a function to be invoked after each test.
Only class member functions should be annotated with AfterTest, the annotated function should not accept any parameters and its return type has to be Unit.
Applying AfterTest to top-level, extension, or object member functions, functions accepting any parameters or functions with a return type other than Unit may lead to compilation or runtime errors, and behavior may vary on different targets.
import kotlin.test.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.*
public class UiTest {
@BeforeTest
public fun setUp() {
Dispatchers.setMain(StandardTestDispatcher)
}
@AfterTest
public fun tearDown() {
Dispatchers.resetMain()
}
@Test
public fun uiTest() { /* ... */}
}Since Kotlin
1.3Marks a function to be invoked after each test.
Only class member functions should be annotated with AfterTest, the annotated function should not accept any parameters and its return type has to be Unit.
Applying AfterTest to top-level, extension, or object member functions, functions accepting any parameters or functions with a return type other than Unit may lead to compilation or runtime errors, and behavior may vary on different targets.
import kotlin.test.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.*
public class UiTest {
@BeforeTest
public fun setUp() {
Dispatchers.setMain(StandardTestDispatcher)
}
@AfterTest
public fun tearDown() {
Dispatchers.resetMain()
}
@Test
public fun uiTest() { /* ... */}
}Since Kotlin
1.8Marks a function to be invoked after each test.
Only class member functions should be annotated with AfterTest, the annotated function should not accept any parameters and its return type has to be Unit.
Applying AfterTest to top-level, extension, or object member functions, functions accepting any parameters or functions with a return type other than Unit may lead to compilation or runtime errors, and behavior may vary on different targets.
import kotlin.test.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.test.*
public class UiTest {
@BeforeTest
public fun setUp() {
Dispatchers.setMain(StandardTestDispatcher)
}
@AfterTest
public fun tearDown() {
Dispatchers.resetMain()
}
@Test
public fun uiTest() { /* ... */}
}