XUnitAssured.Kafka
5.0.0
dotnet add package XUnitAssured.Kafka --version 5.0.0
NuGet\Install-Package XUnitAssured.Kafka -Version 5.0.0
<PackageReference Include="XUnitAssured.Kafka" Version="5.0.0" />
<PackageVersion Include="XUnitAssured.Kafka" Version="5.0.0" />
<PackageReference Include="XUnitAssured.Kafka" />
paket add XUnitAssured.Kafka --version 5.0.0
#r "nuget: XUnitAssured.Kafka, 5.0.0"
#:package XUnitAssured.Kafka@5.0.0
#addin nuget:?package=XUnitAssured.Kafka&version=5.0.0
#tool nuget:?package=XUnitAssured.Kafka&version=5.0.0
XUnitAssured.Net
XUnitAssured.Net is a fluent testing framework for .NET that helps developers create and maintain test collections with the goal of promoting the development of quality software products. Write expressive integration tests using a natural Given().When().Then() DSL for both HTTP/REST APIs and Apache Kafka.
🎯 Features
- Fluent BDD DSL: Write tests in a natural, readable way using
Given().When().Then()syntax - HTTP Testing: Comprehensive HTTP/REST API testing with full CRUD support, JSON path assertions, and schema validation
- Kafka Testing: Integration testing with Apache Kafka — produce/consume single and batch messages with header and key support
- Modular Architecture: Install only what you need (Core, Http, Kafka)
- Multiple HTTP Auth Types: Bearer, BearerWithAutoRefresh, Basic, OAuth2 (Client Credentials, Password, Authorization Code), API Key (Header/Query), Certificate (mTLS), Custom Headers
- Multiple Kafka Auth Types: SASL/PLAIN, SASL/SCRAM-SHA-256, SASL/SCRAM-SHA-512, SSL, Mutual TLS (mTLS)
- Automatic Authentication: Configure auth once in
testsettings.jsonand have it applied automatically to every request - Dependency Injection: Built-in DI support via
DITestFixturebase class - Validation & BDD Extensions:
ValidationBuilderand BDD scenario extensions consolidated in Core - Multi-target Support: Targets
net7.0,net8.0,net9.0, andnet10.0 - xUnit Integration: Seamless integration with xUnit's fixtures and dependency injection
📦 Packages
Core Packages
| Package | Version | Description |
|---|---|---|
| XUnitAssured.Core | 5.0.0 | Core abstractions, DSL infrastructure, DI support (DITestFixture), ValidationBuilder, and BDD extensions |
Protocol Packages
| Package | Version | Description |
|---|---|---|
| XUnitAssured.Http | 5.0.0 | HTTP/REST API testing — fluent DSL, authentication handlers, JSON path assertions, schema validation |
| XUnitAssured.Kafka | 5.0.0 | Apache Kafka integration testing — produce/consume, batch operations, authentication, Schema Registry support |
🚀 Quick Start
HTTP Testing
dotnet add package XUnitAssured.Http
using XUnitAssured.Http.Extensions;
using XUnitAssured.Http.Testing;
public class MyApiTests : HttpTestBase<MyTestFixture>, IClassFixture<MyTestFixture>
{
public MyApiTests(MyTestFixture fixture) : base(fixture) { }
[Fact]
public void Get_Users_Returns_Success()
{
Given()
.ApiResource("/api/users")
.Get()
.When()
.Execute()
.Then()
.AssertStatusCode(200)
.AssertJsonPath<string>("$.name", value => value == "John", "Name should be John");
}
}
HTTP Authentication Examples
// Bearer Token
Given().ApiResource("/api/secure")
.WithBearerToken("my-jwt-token")
.Get()
.When().Execute()
.Then().AssertStatusCode(200);
// Basic Auth
Given().ApiResource("/api/secure")
.WithBasicAuth("username", "password")
.Get()
.When().Execute()
.Then().AssertStatusCode(200);
// API Key (Header or Query)
Given().ApiResource("/api/secure")
.WithApiKey("X-API-Key", "my-api-key", ApiKeyLocation.Header)
.Get()
.When().Execute()
.Then().AssertStatusCode(200);
// OAuth2 Client Credentials
Given().ApiResource("/api/secure")
.WithOAuth2ClientCredentials("https://auth.example.com/token", "client-id", "client-secret")
.Get()
.When().Execute()
.Then().AssertStatusCode(200);
Kafka Testing
dotnet add package XUnitAssured.Kafka
using XUnitAssured.Kafka.Extensions;
using XUnitAssured.Kafka.Testing;
public class MyKafkaTests : KafkaTestBase<KafkaClassFixture>, IClassFixture<KafkaClassFixture>
{
public MyKafkaTests(KafkaClassFixture fixture) : base(fixture) { }
[Fact]
public void Produce_And_Consume_Message()
{
var topic = GenerateUniqueTopic("my-test");
var groupId = $"test-{Guid.NewGuid():N}";
// Produce
Given()
.Topic(topic)
.Produce("Hello, Kafka!")
.When()
.Execute()
.Then()
.AssertSuccess();
// Consume
Given()
.Topic(topic)
.Consume()
.WithGroupId(groupId)
.When()
.Execute()
.Then()
.AssertSuccess()
.AssertMessage<string>(msg => msg.ShouldBe("Hello, Kafka!"));
}
}
Kafka Batch Operations
// Produce batch
Given()
.Topic("my-topic")
.ProduceBatch(messages)
.When()
.Execute()
.Then()
.AssertSuccess()
.AssertBatchCount(5);
// Consume batch
Given()
.Topic("my-topic")
.ConsumeBatch(5)
.WithGroupId(groupId)
.When()
.Execute()
.Then()
.AssertSuccess()
.AssertBatchCount(5);
Kafka Authentication Examples
// SASL/PLAIN
Given().Topic("my-topic")
.Produce("message")
.WithBootstrapServers("localhost:29093")
.WithAuth(auth => auth.UseSaslPlain("user", "password", useSsl: false))
.When().Execute()
.Then().AssertSuccess();
// SSL (one-way)
Given().Topic("my-topic")
.Produce("message")
.WithBootstrapServers("localhost:29096")
.WithAuth(auth => auth.UseSsl("certs/ca-cert.pem"))
.When().Execute()
.Then().AssertSuccess();
// Mutual TLS (mTLS)
Given().Topic("my-topic")
.Produce("message")
.WithBootstrapServers("localhost:29097")
.WithAuth(auth => auth.UseMutualTls("client-cert.pem", "client-key.pem", "ca-cert.pem"))
.When().Execute()
.Then().AssertSuccess();
🏗️ Architecture
XUnitAssured.Core (DSL + Abstractions + DI + ValidationBuilder + BDD Extensions)
↓ ↓
XUnitAssured.Http XUnitAssured.Kafka
(HTTP/REST Testing) (Kafka Integration Testing)
Design Principles:
- SOLID: Each package has a single responsibility
- KISS: Simple, straightforward APIs
- DRY: Reusable components across tests
- YAGNI: Only what you need, when you need it
- Separation of Concerns: Clear boundaries between HTTP, Kafka, and Core
📚 Sample Projects
The repository includes comprehensive sample projects for both local and remote testing:
| Project | Description |
|---|---|
XUnitAssured.Http.Samples.Local.Test |
HTTP tests against a local SampleWebApi (WebApplicationFactory) |
XUnitAssured.Http.Samples.Remote.Test |
HTTP tests against a deployed remote API |
XUnitAssured.Kafka.Samples.Remote.Test |
Kafka tests against local Docker or remote Kafka clusters |
HTTP Sample Test Categories
- SimpleIntegrationTests — Basic GET/POST/PUT/DELETE operations
- CrudOperationsTests — Full CRUD lifecycle with JSON path assertions
- BearerAuthTests — Bearer token authentication
- BasicAuthTests — Basic authentication
- ApiKeyAuthTests — API Key via Header and Query parameter
- OAuth2AuthTests — OAuth2 flows (Client Credentials, Password)
- CertificateAuthTests — Certificate-based (mTLS) authentication
- CustomHeaderAuthTests — Custom header authentication
- HybridValidationTests — Mixed validation strategies
- DiagnosticTests — Connectivity and diagnostic tests
Kafka Sample Test Categories
- ProducerConsumerBasicTests — Produce/consume strings, JSON, headers, batches, keys, timeouts
- AuthenticationPlainTextTests — Plaintext (no auth)
- AuthenticationSaslPlainTests — SASL/PLAIN
- AuthenticationScramSha256Tests — SASL/SCRAM-SHA-256
- AuthenticationScramSha512Tests — SASL/SCRAM-SHA-512
- AuthenticationScramSha512SslTests — SASL/SSL
- AuthenticationTests — SSL, mTLS, invalid credentials
🔄 Version History
v5.0.0 (Current — Core, Http, Kafka)
- Added .NET 10 support across all packages
- Multi-target support:
net7.0,net8.0,net9.0,net10.0 - Unified version across all packages (Core, Http, Kafka)
v4.2.0 (Core)
- Consolidated DI support from
XUnitAssured.DependencyInjectionintoXUnitAssured.Core(DITestFixture)
v4.0.0 (Core + Http)
- Added
ValidationBuilderand BDD extensions (consolidated fromXUnitAssured.Extensions) - Added
HttpValidationBuilderand BDD extensions for HTTP - Multi-target support:
net7.0,net8.0,net9.0
v3.0.0 (Kafka)
- Aligned with framework architecture refactoring
- Full fluent DSL integration for Kafka produce/consume
- Batch operations (
ProduceBatch,ConsumeBatch) - Comprehensive authentication support (SASL, SSL, mTLS)
- Schema Registry support with Avro serialization
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📄 License
This project is licensed under the MIT License - see the LICENSE.md file for details.
👤 Author
Carlos Andrew Costa Bezerra
- Company: R2A Sistemas
- GitHub: @andrewBezerra
🔗 Links
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Confluent.Kafka (>= 2.13.1)
- Confluent.SchemaRegistry (>= 2.13.1)
- Confluent.SchemaRegistry.Serdes.Avro (>= 2.13.1)
- XUnitAssured.Core (>= 5.0.0)
-
net7.0
- Confluent.Kafka (>= 2.3.0)
- Confluent.SchemaRegistry (>= 2.3.0)
- Confluent.SchemaRegistry.Serdes.Avro (>= 2.3.0)
- XUnitAssured.Core (>= 5.0.0)
-
net8.0
- Confluent.Kafka (>= 2.6.1)
- Confluent.SchemaRegistry (>= 2.6.1)
- Confluent.SchemaRegistry.Serdes.Avro (>= 2.6.1)
- XUnitAssured.Core (>= 5.0.0)
-
net9.0
- Confluent.Kafka (>= 2.6.1)
- Confluent.SchemaRegistry (>= 2.6.1)
- Confluent.SchemaRegistry.Serdes.Avro (>= 2.6.1)
- XUnitAssured.Core (>= 5.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 5.0.0 | 90 | 2/23/2026 |