Migrating from JUnit + RestAssured to the Mockarty Tester
JUnit + RestAssured is the canonical Java HTTP test stack. The
Mockarty Tester DSL offers a drop-in alternative with multi-protocol
reach (gRPC / GraphQL / Kafka / WebSocket / SOAP / DB beyond HTTP)
and first-class Allure / TCM integration.
At a glance
| RestAssured | Mockarty Tester (Java) |
|---|---|
given().get(url) |
t.http().get(url) |
.statusCode(200) |
.expectStatus(200) |
.body("name", equalTo("Alice")) |
.expectJsonPath("$.name", "Alice") |
.body("roles.size()", equalTo(2)) |
.expectJsonArrayLen("$.roles", 2) |
.header("X", equalTo("y")) |
.expectHeader("X", "y") |
.body(json("...")) request body |
.json(Map.of(...)) |
extract().path("$.token") |
.extract("$.token", "token") |
header("Authorization", token) |
.header("Authorization", token) |
| RequestSpecBuilder builder | Tester.Builder |
@BeforeEach setup |
Plain Java code before the chain |
Side-by-side example
RestAssured + JUnit 5
import io.restassured.RestAssured;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
class LoginFlowTest {
@Test
void loginAndMe() {
RestAssured.baseURI = "http://localhost:8080";
String token = given()
.contentType("application/json")
.body("{\"user\":\"alice\"}")
.post("/login")
.then().statusCode(200)
.extract().path("$.token");
given()
.header("Authorization", "Bearer " + token)
.get("/me")
.then().statusCode(200)
.body("user", equalTo("alice"));
}
}
Mockarty Tester
import ru.mockarty.tester.Tester;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
class LoginFlowTest {
@Test
void loginAndMe() {
Tester t = new Tester.Builder().baseUrl("http://localhost:8080").build();
t.http().post("/login")
.json(Map.of("user", "alice"))
.expectStatus(200)
.extract("$.token", "token");
t.http().get("/me")
.header("Authorization", "Bearer {{token}}")
.expectStatus(200)
.expectJsonPath("$.user", "alice");
t.finish();
assertTrue(t.ok(), () -> t.errors().toString());
}
}
Why migrate
- One DSL, many protocols. Replacing RestAssured + Pact + a Kafka
consumer test + a gRPC stub with oneTesterchain that calls
.http(),.kafka(client),.grpc(client)in sequence and
shares the{{var}}store across them. - Allure-ready output. Wrap the test with the SDK Allure scope
and every chain call lands as an Allure step. - TCM upload in one call.
ExternalRunBridge.toExternalRunRequest(t, opts)
maps the Tester result to a TCM external-run payload — ship to
the Mockarty admin server and the run shows up in the test plan.
Reporting back to Mockarty TCM
import ru.mockarty.tester.ExternalRunBridge;
client.externalRuns().report("qa",
ExternalRunBridge.toExternalRunRequest(t,
new ExternalRunBridge.Options()
.caseName("Login flow")
.autoCreate(true)));
See the Java SDK README
for the full chain reference and protocol-specific facets.