AfterTest

@Target(allowedTargets = [AnnotationTarget.FUNCTION])
expect annotation class AfterTest(source)

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.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest(source)

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.1
actual typealias AfterTest = After(source)

Since Kotlin

1.0
actual typealias AfterTest = AfterEach

Since Kotlin

1.0
actual typealias AfterTest = AfterMethod

Since Kotlin

1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest(source)

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.3
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest(source)

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.8
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest(source)

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.8