BeforeTest

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

Marks a function to be invoked before each test.

Only class member functions should be annotated with BeforeTest, the annotated function should not accept any parameters and its return type has to be Unit.

Applying BeforeTest 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 BeforeTest(source)

Marks a function to be invoked before each test.

Only class member functions should be annotated with BeforeTest, the annotated function should not accept any parameters and its return type has to be Unit.

Applying BeforeTest 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 BeforeTest = Before(source)

Since Kotlin

1.0
actual typealias BeforeTest = BeforeEach

Since Kotlin

1.0
actual typealias BeforeTest = BeforeMethod

Since Kotlin

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

Marks a function to be invoked before each test.

Only class member functions should be annotated with BeforeTest, the annotated function should not accept any parameters and its return type has to be Unit.

Applying BeforeTest 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 BeforeTest(source)

Marks a function to be invoked before each test.

Only class member functions should be annotated with BeforeTest, the annotated function should not accept any parameters and its return type has to be Unit.

Applying BeforeTest 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 BeforeTest(source)

Marks a function to be invoked before each test.

Only class member functions should be annotated with BeforeTest, the annotated function should not accept any parameters and its return type has to be Unit.

Applying BeforeTest 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