SDK quick start
Mockarty ships first-class SDKs for Go, Python, and Java so
your tests live next to your application code rather than in a separate
DSL. The SDKs let you:
- Drive Mockarty from a unit / integration test (create mocks, run perf
scripts, assert results). - Emit conformant Allure 2 reports without
going through the CLI runner. - Use Mockarty as a Pact-style contract
verifier inside your existing test framework. - Run a CI step against a Mockarty test container
that the SDK starts and tears down — no standing admin node needed.
If you’d rather author tests in JavaScript / TypeScript, the perf runner
already accepts k6-compatible scripts (see
Performance testing). The SDKs are for
teams that want typed test code in the same language as the service under
test.
Why use an SDK
- Native test framework integration.
go test,pytest,JUnit 5
run your Mockarty assertions like any other test. - No DSL learning curve. Use your IDE’s autocomplete, your usual
refactor tools. - Programmatic mock setup. Build complex fixtures (matrix of
combinations) in code instead of YAML. - CI without a standing server. The SDK can start a Mockarty
test container for the test run and tear it down
after — no permanently-running admin node required.
Packages and requirements
| SDK | Package | Version | Requirements |
|---|---|---|---|
| Go | github.com/mockarty/go-sdk |
v0.4.0+ | Go 1.25+ |
| Python | mockarty (PyPI) |
0.4.0 | Python 3.9+ |
| Java | ru.mockarty:mockarty-java (Maven Central) |
0.4.0 | Java 11+ |
The SDKs drive a running Mockarty over its REST API, so a current server
release works with any of them. Use the newest SDK release: it adds methods
for newer endpoints, while older SDKs keep working against newer servers.
Go module path. The Go SDK moved to
github.com/mockarty/go-sdkin
v0.4.0 (earlier tags usedgithub.com/mockarty/mockarty-go). Require
v0.4.0 or newer ingo.mod.
Install
Go
go get github.com/mockarty/go-sdk@v0.4.0
Python
pip install mockarty
Java
<dependency>
<groupId>ru.mockarty</groupId>
<artifactId>mockarty-junit5</artifactId>
<version>0.4.0</version>
<scope>test</scope>
</dependency>
Gradle: testImplementation 'ru.mockarty:mockarty-junit5:0.4.0'.
mockarty-junit5 brings the core client (mockarty-java) in transitively —
one dependency covers the whole example below. If you don’t use JUnit 5,
depend on ru.mockarty:mockarty-java directly instead.
First mock
Each SDK is a typed REST client. Point it at a running Mockarty (a local
admin node or a test container you start in CI),
create a mock, and call it through /stubs/<namespace>/<route>.
Go
package mock_test
import (
"context"
"testing"
mockarty "github.com/mockarty/go-sdk"
)
func TestCheckoutStub(t *testing.T) {
ctx := context.Background()
client := mockarty.NewClient("http://localhost:5770",
mockarty.WithAPIKey("mk_your_api_key"),
mockarty.WithNamespace("sandbox"),
)
mock := mockarty.NewMockBuilder().
ID("charge-ok").
HTTP(func(h *mockarty.HTTPBuilder) {
h.Route("/v1/charge").Method("POST")
}).
Response(func(r *mockarty.ResponseBuilder) {
r.Status(200).JSONBody(map[string]any{"id": "ch_123", "status": "succeeded"})
}).
Build()
// Overwrite() keeps the call repeatable: a re-run replaces the mock
// instead of failing with a duplicate-mock conflict.
saved, err := client.Mocks().Create(ctx, mock, mockarty.Overwrite())
if err != nil {
t.Fatal(err)
}
defer client.Mocks().Delete(ctx, saved.ID)
// Your code under test calls http://localhost:5770/stubs/sandbox/v1/charge
}
Python
from mockarty import MockartyClient, MockBuilder
def test_checkout_stub():
with MockartyClient(
base_url="http://localhost:5770",
api_key="mk_your_api_key",
namespace="sandbox",
) as client:
mock = (
MockBuilder.http("/v1/charge", "POST")
.id("charge-ok")
.respond(200, body={"id": "ch_123", "status": "succeeded"})
.build()
)
# intent="overwrite" keeps the call repeatable.
saved = client.mocks.create(mock, intent="overwrite")
# Your code under test calls http://localhost:5770/stubs/sandbox/v1/charge
client.mocks.delete(saved.id)
Java
import ru.mockarty.MockartyClient;
import ru.mockarty.builder.MockBuilder;
import ru.mockarty.junit5.MockartyTest;
import ru.mockarty.model.SaveMockResponse;
import org.junit.jupiter.api.Test;
// @MockartyTest connects to a running Mockarty (MOCKARTY_BASE_URL /
// MOCKARTY_API_KEY or annotation parameters) and injects a ready client.
// cleanupAfterEach removes mocks registered through MockartyServer.
@MockartyTest(namespace = "sandbox", cleanupAfterEach = true)
class CheckoutTest {
@Test
void chargeStub(MockartyClient client) {
SaveMockResponse saved = client.mocks().create(
MockBuilder.http("/v1/charge", "POST")
.id("charge-ok")
.respond(200, "{\"id\":\"ch_123\",\"status\":\"succeeded\"}")
.build(),
"overwrite");
// Your code under test calls <server>/stubs/sandbox/v1/charge
client.mocks().delete(saved.getId());
}
}
Language notes:
- Go — pass the server URL to
NewClient, the token through
WithAPIKey, and the default namespace throughWithNamespace. - Python — the SDK plays nicely with
pytestfixtures: wrap
MockartyClientin a fixture and share it across the suite. - Java —
@MockartyTestconnects to (or, with the test-container
extension, starts) a Mockarty server and injects aMockartyClient.
Full guide and reference: SDK guide. For a server in CI
without a standing admin node, use the test container.
Which SDK fits which workflow
| You want to… | Use… |
|---|---|
| Add mocks to a Go integration test | Go SDK |
Add mocks to a pytest suite |
Python SDK |
| Add mocks to a Spring Boot / JUnit 5 suite | Java SDK |
| Write a perf script that runs in the runner cluster | k6-compat JS — see Performance testing |
| Author functional tests with Mockarty assertions | flow.mockarty.json manifests — see CLI user guide |
| Drive Mockarty from CI without a standing server | Any SDK + a test container |
| Send Allure-annotated results to a shared dashboard | Any SDK + the Allure writer — see Allure annotations |
What’s NOT in the SDK
By design, the SDKs cover CI / scripting / end-user-test surface
only. They do not expose:
- Admin operations (user management, licence management, audit-log
export, cluster operations) — these stay in the Web UI / REST API. - Workspace settings.
- Token issuance / revocation (only via Web UI or admin REST API).
- Webhook / channel configuration.
If you have a use case for a missing SDK method, please open an issue
on the corresponding SDK repository. SDK scope grows on demand, not
mechanically with the REST surface.
SDK source code
| SDK | Repository |
|---|---|
| Go | github.com/mockarty/go-sdk |
| Python | github.com/mockarty/py-sdk |
| Java | github.com/mockarty/java-sdk |
Each repository contains an examples/ directory with runnable
scenarios. The examples track the SDK’s main branch and are
versioned alongside the SDK release.
Where to next
- SDK guide — full per-language API reference.
- Allure annotations — rich report metadata.
- CLI command reference — what’s available
outside the SDK. - Quick start — create and test your first mock.