Java SDK

The Antithesis Java SDK offers classes to use Antithesis functionality in your Java code under test. It’s available on Github and as a JAR on Maven Central.

Prerequisites

  • Java 8 or higher.

If you want to use a different version, contact us at support@antithesis.com or ask on our Discord.

Classes

The SDK provides three classes which each offer different functionality.

SDK runtime behavior

The SDK has sensible fallback behaviors that enable you to have a single build of your software that runs both inside and outside Antithesis.

One benefit of this is that Sometimes Assertions continue to function outside Antithesis, and can be quite useful for discovering what states of your program are encountered during real-world use.

Fallback behavior for methods in Assert and Lifecycle

Methods in the Assert and Lifecycle classes have two modes for when your software is running outside Antithesis, including in production:

  1. Default This mode is the default behavior, where assert and lifecycle use local implementations of Antithesis functionality. However, the results will not be logged anywhere because no logfile has been specified.

  2. Default with logging The same as the above but logs output locally in a structured JSON format.

    This mode is useful for dicovering what states of your program are encountered during real-world use.

    This mode is selected at runtime by setting the environment variable ANTITHESIS_SDK_LOCAL_OUTPUT at program startup. This variable must be set to a filepath: a logfile will be created at this location. The file must be located inside an already-existing directory. You may supply either a relative or absolute path.

    E.g. set ANTITHESIS_SDK_LOCAL_OUTPUT=assertions_20240520.json at startup.

Fallback behavior for methods in Random

Methods in the Random class always fall back upon the java.util.Random class for entropy when run outside of Antithesis.

Further reading

Here’s a tutorial to familiarize you.

References to the classes provided by the SDK.

  • Introduction
  • How Antithesis works
  • Using Antithesis documentation with AI
  • Get started
  • Test an example system
  • With Docker Compose
  • Build and run an etcd cluster
  • Meet the Test Composer
  • With Kubernetes
  • Build and run an etcd cluster
  • Meet the Test Composer
  • Setup guide
  • For Docker Compose users
  • For Kubernetes users
  • Product
  • Test Composer
  • Test Composer basics
  • Test Composer commands
  • How to check test templates locally
  • How to port tests to Antithesis
  • Test launchers
  • Reports
  • The triage reports
  • Findings
  • Environment
  • Utilization
  • Properties
  • The bug reports
  • Context, Instance, & Logs
  • Bug likelihood over time
  • Logs Explorer & multiverse map
  • Multiverse debugging
  • Overview
  • The Antithesis multiverse
  • Querying with event sets
  • Environment utilities
  • Using the Antithesis Notebook
  • Cookbook
  • Tooling integrations
  • CI integration
  • Discord and Slack integrations
  • Issue tracker integration - BETA
  • Configuration
  • Access and authentication
  • The Antithesis environment
  • Optimizing for testing
  • Docker best practices
  • Kubernetes best practices
  • Concepts
  • Properties and Assertions
  • Properties in Antithesis
  • Assertions in Antithesis
  • Sometimes Assertions
  • Properties to test for
  • Fault injection
  • Reference
  • Webhooks
  • Launching a test
  • Launching a debugging session
  • Webhook parameters
  • SDK reference
  • Define test properties
  • Generate randomness
  • Manage test lifecycle
  • Assertion catalog
  • Coverage instrumentation
  • Go
  • Instrumentor
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Java
  • Using the SDK
  • Building your software
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • C
  • C++
  • C/C++ Instrumentation
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • JavaScript
  • Python
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Rust
  • Instrumentation
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • .NET
  • Instrumentation
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Languages not listed above
  • Assert (reference)
  • Lifecycle (reference)
  • Assertion Schema
  • Handling external dependencies
  • FAQ
  • Product FAQs
  • About Antithesis POCs
  • Release notes
  • Release notes
  • General reliability resources
  • Reliability glossary
  • White paper — How much does an outage cost?
  • Autonomous testing
  • Deterministic simulation testing
  • Property-based testing
  • Catalog of reliability properties for key-value datastores
  • Catalog of reliability properties for blockchains
  • Techniques to improve software testing
  • Test ACID compliance with a ring test