TestNG
dependencies {
testImplementation("dev.tracera:tracera-testng:<version>")
}
Requires JDK ≥ 17 and TestNG ≥ 7 (see Autotest adapters). tracera-testng on Maven Central.
Environment variables, run mode, and retries: Autotest adapters.
Retry Env key: TESTNG_RETRY.
The listener registers via ServiceLoader. You can also add @Listeners(TraceraTestNgListener::class).
Bind testCaseId and autotestName
Import stock TestNG APIs, and Tracera from dev.tracera.
At declaration (preferred — bind runs even if the body skips early):
import dev.tracera.Tracera
import org.testng.annotations.Test
class LoginTest {
@Tracera.Id(42, name = "e2e/login")
@Test
fun login() {
assert(true)
}
}
Inside the test:
import dev.tracera.Tracera
import org.testng.annotations.Test
class LoginTest {
@Test
fun login() {
Tracera.testCase(42, "e2e/login")
assert(true)
}
}
Skip
Use stock TestNG skip (throw SkipException(…), enabled = false, …). 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 @BeforeMethod / @AfterMethod go to Setup / Teardown; steps inside the test go to Test. Suite / class configuration methods are not reported.
import dev.tracera.Tracera
import org.testng.annotations.BeforeMethod
import org.testng.annotations.Test
class CheckoutTest {
@BeforeMethod
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 the @Test method that uses a DataProvider, or call Tracera.testCase inside when the case id varies per row. Optional name may use {arg} / {param_id} from the method arguments. If name is omitted, autotestName takes the value of the TestNG method name.
@Tracera.Id(42, name = "login as {login}")
@Test(dataProvider = "logins")
fun login(login: String) {
assert(login.isNotEmpty())
}