JUnit 5
dependencies {
testImplementation("dev.tracera:tracera-junit5:<version>")
}
Requires JDK ≥ 17 and JUnit ≥ 5.8 (see Autotest adapters). tracera-junit5 on Maven Central.
Environment variables, run mode, and retries: Autotest adapters.
Retry Env key: JUNIT_RETRY.
Enable automatic extension registration (once per project):
# src/test/resources/junit-platform.properties
junit.jupiter.extensions.autodetection.enabled=true
Or register explicitly with @ExtendWith(TraceraExtension::class).
Bind testCaseId and autotestName
Import stock JUnit Jupiter APIs, and Tracera from dev.tracera.
At declaration (preferred — bind runs even if the body skips early):
import dev.tracera.Tracera
import org.junit.jupiter.api.Test
class LoginTest {
@Tracera.Id(42, name = "e2e/login")
@Test
fun login() {
assert(true)
}
}
Inside the test:
import dev.tracera.Tracera
import org.junit.jupiter.api.Test
class LoginTest {
@Test
fun login() {
Tracera.testCase(42, "e2e/login")
assert(true)
}
}
Skip
Use stock JUnit skip (Assumptions.abort, @Disabled, …). The skip reason is added to the result as comment.
Steps
Use Tracera.step("…") { … }, Tracera.suspendStep("…") { … } for coroutines, or put @Tracera.Step("…") on a method (sync and suspend). With @Tracera.Step, if the title is empty or omitted, the step title becomes the method name; {0} / {name} in the title are filled from the method arguments. Steps inside @BeforeEach / @AfterEach go to the result’s Setup / Teardown; steps inside the test go to Test. @BeforeAll / @AfterAll are not reported.
import dev.tracera.Tracera
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Test
class CheckoutTest {
@BeforeEach
fun openShop() {
Tracera.step("open shop") { }
}
@Tracera.Step("add {sku}")
fun addSku(sku: String) {
}
@Tracera.Id(10, name = "e2e/checkout")
@Test
fun checkout() {
addSku("SKU-1")
Tracera.step("pay") { }
}
}
Comments, errors, and attachments
Comments, errors, and attachments: Autotest adapters.
Tracera.comment("result-level note")
Tracera.error("result-level error text")
Tracera.step("open login") {
Tracera.comment("landed on login")
}
Parameterized tests
Put @Tracera.Id on each @ParameterizedTest method (same id for every row, or call Tracera.testCase inside when the id varies). Optional name may include placeholders: {login} (and other argument names) from the method parameters, or {param_id} for the JUnit test name. If name is omitted, autotestName takes the value of the JUnit test name.
@Tracera.Id(42, name = "login as {login}")
@ParameterizedTest
@ValueSource(strings = ["ok", "sso"])
fun login(login: String) {
assert(login.isNotEmpty())
}