What is Antithesis? How we're different Problems we solve Security approach Demo Fintech Blockchain Databases Customer stories Working with Antithesis Contact us Backstory Leadership Careers Brand Distributed systems reliability glossary Cost of outages white paper Deterministic simulation testing Property-based testing

.NET SDK

Overview

The Antithesis .NET SDK offers classes for placing your .NET code under test and using Antithesis functionality. It is available on Github and as a package on NuGet.

The Antithesis .NET SDK is intended for use with .NET 6 or higher. If you want to use a different version reach out to us at support@antithesis.com.

Classes

The SDK provides three classes which each offer different functionality.

  • The Assert class methods define test properties about your software or workload.
  • The Random class is a subclass of System.Random that encapsulates Antithesis’s deterministic and reproducible random number generator.
  • The Lifecycle class methods inform the Antithesis environment that particular test phases or milestones have been reached.

Using the .NET SDK

The basic workflow for using the .NET SDK is:

  1. Add a PackageReference to Antithesis.SDK to your .NET project file.

    E.g. <PackageReference Include="Antithesis.SDK" Version="1.0.31" />

  2. Call SDK methods from your code.

    E.g. Assert.Always(someCondition).

  3. Build your .NET project.

  4. Deploy your build: either to Antithesis or into production.

SDK runtime behavior

The SDK is designed to have sensible fallback behavior that enables 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.

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

  1. Default, where Assert and Lifecycle use local implementations of Antithesis functionality. However, the results will not be logged anywhere because no logfile has been specified.

    This mode is the default behavior.

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

    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.json prior to startup to output logs to assertions.json.

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

Further reading

  • Introduction
  • How Antithesis Works
  • Tutorial
  • Testing with Antithesis
  • Build and run an etcd cluster
  • Meet the Test Composer
  • User manual
  • Setup guide
  • Properties and Assertions
  • Properties in Antithesis
  • Assertions in Antithesis
  • Sometimes Assertions
  • Properties to test for
  • Test Composer
  • Test Composer basics
  • Test Composer reference
  • Principles of test composition
  • Checking test templates locally
  • Getting started with Test Composer
  • Webhooks
  • Launching a test
  • Retrieving logs
  • Launching a debugging session
  • Webhook API
  • Reports
  • The triage report
  • Findings
  • Environment
  • Utilization
  • Properties
  • The bug report
  • Context, Instance, & Logs
  • Bug likelihood over time
  • Statistical debug information
  • Search dashboard & multiverse map
  • Multiverse debugging
  • Overview
  • The Antithesis multiverse
  • Querying with event sets
  • The Environment and its utilities
  • Using the Antithesis Notebook
  • Cookbook
  • Antithesis' testing environment
  • The Antithesis Environment
  • Fault Injection
  • CPUID
  • Reference
  • Handling External Dependencies
  • SDK reference
  • Go
  • Tutorial
  • Instrumentor
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Java
  • Tutorial
  • Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • C
  • C++
  • Tutorial
  • C/C++ Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • JavaScript
  • Python
  • Tutorial
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Rust
  • Tutorial
  • Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • .NET
  • Tutorial
  • Instrumentation
  • Assert (reference)
  • Lifecycle (reference)
  • Random (reference)
  • Languages not listed above
  • Assert (reference)
  • Lifecycle (reference)
  • Assertion Schema
  • Tooling integrations
  • CI integration
  • Discord and Slack integrations
  • Issue tracker integration - BETA
  • Configuring Antithesis
  • Instrumentation
  • User management
  • Sizing your deployment
  • Best practices
  • Docker best practices
  • Is Antithesis working?
  • Optimizing for Antithesis
  • Finding more bugs
  • FAQ
  • About Antithesis POCs
  • Product FAQs
  • Release notes
  • Release notes