Get started

Getting Started

Test runners

Introduction

CSTesting does not integrate with JUnit or TestNG. It provides its own test runner (CSTestingRunner) and annotations (@CSTest, @BeforeMethod, @AfterMethod, @BeforeClass, @AfterClass, @BeforeSuite, @AfterSuite). You run tests by passing your test class to the runner from code or from the command line (Maven or Gradle). Each test method runs in a new browser for isolation; the runner creates and closes the browser for you.

Supported: CSTestingRunner (built-in)

CSTesting's only supported way to run annotated tests is CSTestingRunner.

  • Your test class extends CSTestingTestBase and uses @CSTest, @BeforeMethod, @AfterMethod, etc.
  • The runner creates one CSTestingBrowser per test method, injects it, runs the test, then closes the browser.
  • There is no BrowserContext or Page abstraction; CSTestingBrowser is the single object you use (like a "page" that can navigate and interact).

From code:

public static void main(String[] args) {
    CSTestingRunner.run(MyTest.class);
}

From command line (Maven):

mvn exec:java -Dexec.mainClass="com.cstesting.runner.CSTestingRunner" -Dexec.args="com.example.MyTest"

See Annotations and Running and debugging tests for details.

Not supported: JUnit

CSTesting does not integrate with JUnit. There is no JUnit dependency, no JUnit-specific APIs, and no "run with JUnit" setup.

Use CSTestingRunner and CSTesting annotations instead. The annotation names (@BeforeMethod, @AfterMethod, @BeforeClass, @AfterClass) are similar to TestNG; the lifecycle is implemented by CSTestingRunner, not by JUnit or TestNG.

Not supported: TestNG

CSTesting does not integrate with TestNG. There is no TestNG dependency and no TestNG-specific setup.

CSTesting's annotations are inspired by TestNG (e.g. @BeforeMethod, @AfterMethod, @BeforeClass, @AfterClass), but tests are run by CSTestingRunner, not by the TestNG engine. You cannot run CSTesting tests with @Test from TestNG; use @CSTest and CSTestingRunner.run(MyTest.class).

Supported: Maven

You can run CSTesting tests with Maven using the exec-maven-plugin:

mvn exec:java -Dexec.mainClass="com.cstesting.runner.CSTestingRunner" -Dexec.args="com.example.MyTest"

Or add a profile in your pom.xml and run:

mvn exec:java -Pannotation-tests

Dependency:

<dependency>
  <groupId>io.github.cstesttool</groupId>
  <artifactId>cstesting-java</artifactId>
  <version>0.1.5</version>
</dependency>

Supported: Gradle

CSTesting works with Gradle as the build tool. Add the dependency and run the runner with a JavaExec task.

build.gradle (Kotlin):

plugins {
    java
    application
}

repositories {
    mavenCentral()
}

dependencies {
    implementation("io.github.cstesttool:cstesting-java:0.1.5")
}

application {
    mainClass.set("com.cstesting.runner.CSTestingRunner")
}

// Run one test class: ./gradlew run --args="com.example.MyTest"
tasks.named<JavaExec>("run") {
    if (project.hasProperty("testClass")) {
        args(project.property("testClass"))
    }
}

Run:

./gradlew run --args="com.example.MyTest"

Or define a dedicated task:

tasks.register<JavaExec>("cstesting") {
    group = "verification"
    classpath = sourceSets["main"].runtimeClasspath
    mainClass.set("com.cstesting.runner.CSTestingRunner")
    if (project.hasProperty("testClass")) {
        args(project.property("testClass"))
    }
}
./gradlew cstesting -PtestClass=com.example.MyTest

build.gradle (Groovy):

plugins {
    id 'java'
    id 'application'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'io.github.cstesttool:cstesting-java:0.1.5'
}

application {
    mainClass = 'com.cstesting.runner.CSTestingRunner'
}

run {
    if (project.hasProperty('testClass')) {
        args project.testClass
    }
}

Parallel execution

CSTestingRunner runs all @CSTest methods in a class sequentially on a single thread. There is no built-in parallel execution (no parallel test methods or parallel classes within the same JVM).

If you need parallelism, you can run multiple test classes in separate processes (e.g. multiple Maven/Gradle invocations with different class names), each using CSTestingRunner. That is not an official integration; it is a usage pattern you can implement in your build or scripts.

Summary

Runner / buildSupported?Notes
CSTestingRunnerYesBuilt-in; only supported way to run @CSTest methods.
JUnitNoNot integrated; use CSTestingRunner.
TestNGNoNot integrated; use CSTestingRunner (annotations are TestNG-style only).
MavenYesUse exec:java with CSTestingRunner and test class name.
GradleYesUse JavaExec with main class CSTestingRunner and args = test class name.
Parallel (in-process)NoRunner is single-threaded; tests run one after another.