Kotlin test annotations for use in common code, providing @Test, @Ignore, @BeforeTest, and @AfterTest annotations for multiplatform testing.
npx @tessl/cli install tessl/maven-org-jetbrains-kotlin--kotlin-test-annotations-common@2.2.0Kotlin test annotations for use in common code. Provides common test annotations like @Test, @Ignore, @BeforeTest, and @AfterTest that can be used across different platforms in Kotlin multiplatform projects.
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common:2.2.0")<dependency><groupId>org.jetbrains.kotlin</groupId><artifactId>kotlin-test-annotations-common</artifactId><version>2.2.0</version></dependency>import kotlin.test.*Or import specific annotations:
import kotlin.test.Test
import kotlin.test.Ignore
import kotlin.test.BeforeTest
import kotlin.test.AfterTestimport kotlin.test.*
class MyTest {
@BeforeTest
fun setup() {
// Setup code that runs before each test
}
@Test
fun testSomething() {
// Test implementation
}
@Test
fun testAnotherThing() {
// Another test implementation
}
@Ignore
@Test
fun testSkipped() {
// This test will be ignored/skipped
}
@AfterTest
fun teardown() {
// Cleanup code that runs after each test
}
}Mark functions as test methods that should be executed by the test framework.
@Target(AnnotationTarget.FUNCTION)
public expect annotation class Test()The @Test annotation marks a function as a test that should be executed by the testing framework. This annotation is mapped to platform-specific test annotations:
@Test, JUnit 5's @Test, or TestNG's @TestSkip test execution for specific tests or entire test suites.
@Target(AnnotationTarget.CLASS, AnnotationTarget.FUNCTION)
public expect annotation class Ignore()The @Ignore annotation can be applied to:
When applied, the test framework will skip execution but typically report the test as ignored/skipped.
Execute setup code before each test method.
@Target(AnnotationTarget.FUNCTION)
public expect annotation class BeforeTest()Functions annotated with @BeforeTest are executed before each test method in the same class. This is useful for:
Execute cleanup code after each test method.
@Target(AnnotationTarget.FUNCTION)
public expect annotation class AfterTest()Functions annotated with @AfterTest are executed after each test method in the same class. This is useful for:
These annotations are expect declarations that map to platform-specific testing frameworks:
@org.junit.Test, @org.junit.Ignore, @org.junit.Before, @org.junit.After@org.junit.jupiter.api.Test, @org.junit.jupiter.api.Disabled, @org.junit.jupiter.api.BeforeEach, @org.junit.jupiter.api.AfterEach@org.testng.annotations.Test, @org.testng.annotations.Test(enabled=false), @org.testng.annotations.BeforeMethod, @org.testng.annotations.AfterMethodit(), xit() or it.skip(), beforeEach(), afterEach()Maps to the testing framework available on the specific native platform.
commonMain or commonTest source sets@BeforeTest methods run before each @Test method, and @AfterTest methods run after each @Test method@Ignore can be applied to both classes and functions, while other annotations only apply to functions