XUnitAssured.Mcp
MCP (Model Context Protocol) server for AI-assisted test generation with XUnitAssured. Provides 10 tools for translating Playwright Inspector code to fluent DSL, scaffolding HTTP/REST CRUD tests, and generating Kafka produce/consume tests. Integrates with GitHub Copilot Chat, VS Code, Visual Studio, and any MCP-compatible client via stdio transport.
Ask AI about XUnitAssured.Mcp
Powered by Claude Β· Grounded in docs
I know everything about XUnitAssured.Mcp. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
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 HTTP/REST APIs, Apache Kafka, and browser-based UI testing with Playwright. Includes an MCP (Model Context Protocol) server for AI-assisted test generation.
π― 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
- Playwright UI Testing: Browser-based UI testing with fluent DSL for clicks, fills, checks, navigation, screenshots, and rich assertions β built on Microsoft Playwright
- MCP Server: AI-assisted test generation via Model Context Protocol β translate Playwright code, scaffold HTTP/Kafka tests directly from Copilot Chat
- Modular Architecture: Install only what you need (Core, Http, Kafka, Playwright)
- 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 |
| XUnitAssured.Playwright | 5.0.0 | Playwright UI testing β fluent DSL for browser interactions, multiple locator strategies, screenshots, and assertions |
Tooling
| Package | Description |
|---|---|
| XUnitAssured.Mcp | MCP server for AI-assisted test generation β integrates with GitHub Copilot Chat, VS Code, and any MCP-compatible client |
π 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);
Playwright UI Testing
dotnet add package XUnitAssured.Playwright
using XUnitAssured.Playwright.Extensions;
using XUnitAssured.Playwright.Testing;
public class MyUiTests : PlaywrightTestBase<MyPlaywrightFixture>, IClassFixture<MyPlaywrightFixture>
{
public MyUiTests(MyPlaywrightFixture fixture) : base(fixture) { }
[Fact]
public void Login_Should_Navigate_To_Dashboard()
{
Given()
.NavigateTo("/login")
.FillByLabel("Email", "user@test.com")
.FillByLabel("Password", "secret")
.ClickByRole(AriaRole.Button, "Sign in")
.When()
.Execute()
.Then()
.AssertSuccess()
.AssertUrl("/dashboard");
}
}
Playwright Codegen Integration
Record tests with Playwright Inspector and translate to XUnitAssured DSL:
// Playwright Inspector output:
await page.GetByRole(AriaRole.Button, new() { Name = "Click me" }).ClickAsync();
await page.GetByLabel("Email").FillAsync("user@test.com");
// XUnitAssured DSL (auto-translated):
.ClickByRole(AriaRole.Button, "Click me")
.FillByLabel("Email", "user@test.com")
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)
β β β
XUnitAssured.Http XUnitAssured.Kafka XUnitAssured.Playwright
(REST API Testing) (Kafka Testing) (UI Testing)
β
XUnitAssured.Mcp
(AI-Assisted Test Generation)
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, Playwright, 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 |
XUnitAssured.Playwright.Samples.Local.Test | Playwright UI tests against a local Blazor SampleWebApp |
XUnitAssured.Playwright.Samples.Remote.Test | Playwright UI tests against a deployed remote web application |
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
Playwright Sample Test Categories
- HomePageTests β Page navigation, title verification, element visibility
- CounterPageTests β Button clicks, state changes, counter increments
- LoginPageTests β Form fills, authentication flows, error validation
- RegisterPageTests β Multi-field forms, validation messages
- NavigationTests β Menu navigation, URL assertions, page transitions
- WeatherPageTests β Data table assertions, loading states
- TodoCrudTests β Full CRUD UI operations (create, read, update, delete)
π€ MCP Server (AI-Assisted Test Generation)
XUnitAssured includes an MCP (Model Context Protocol) server that integrates with GitHub Copilot Chat, VS Code, and any MCP-compatible AI client. It provides 10 tools for test generation and code translation.
Available Tools
| Tool | Description |
|---|---|
translate_playwright_to_dsl | Translates Playwright C# Inspector code β XUnitAssured fluent DSL |
translate_playwright_to_test | Generates a complete Given/When/Then test from Playwright code |
list_xunitassured_dsl_methods | Lists all Playwright DSL methods with equivalents |
generate_http_test | Scaffolds an HTTP test method (GET, POST, PUT, DELETE) |
generate_http_crud_tests | Generates 5 CRUD test methods for a REST resource |
list_http_dsl_methods | Lists all HTTP DSL methods (request, auth, assert) |
generate_kafka_produce_test | Scaffolds a Kafka produce test method |
generate_kafka_consume_test | Scaffolds a Kafka consume test method |
generate_kafka_produce_consume_test | Generates a round-trip produceβconsume test |
list_kafka_dsl_methods | Lists all Kafka DSL methods (produce, consume, auth, assert) |
Setup
1. Build the MCP server
cd src/XunitAssured.MCP
dotnet build -c Debug
2. Configure .mcp.json
The MCP server uses stdio transport. You can configure it at the repo level (.mcp.json at the repo root) or globally (~/.mcp.json in your home directory).
Option A β Repo-level (relative path, recommended for team use):
Create a .mcp.json file at the repository root:
{
"servers": {
"xunitassured": {
"type": "stdio",
"command": "dotnet",
"args": ["run", "--no-build", "--project", "src/XunitAssured.MCP/XunitAssured.MCP.csproj"]
}
}
}
Option B β Global (absolute path, recommended for personal use):
Create or edit ~/.mcp.json (e.g., C:\Users\<you>\.mcp.json on Windows):
{
"servers": {
"xunitassured": {
"type": "stdio",
"command": "<full-path-to-repo>/XUnitAssured.Mcp.exe",
"args": []
}
}
}
Tip: Pointing directly to the compiled
.exeis faster thandotnet runbecause it skips project resolution. Use forward slashes or escaped backslashes (\\) on Windows.
3. Restart your IDE
Visual Studio / VS Code must be restarted after creating or editing .mcp.json for the MCP server to be detected.
4. Verify
In GitHub Copilot Chat, the XUnitAssured tools should appear as available. Try:
"List all XUnitAssured HTTP DSL methods"
Usage in Copilot Chat
"Generate CRUD tests for /api/products with fields name:string, price:decimal"
"Translate this Playwright code to XUnitAssured DSL:
await page.GetByRole(AriaRole.Button, new() { Name = \"Submit\" }).ClickAsync();"
"Generate a Kafka produce-consume round-trip test for the orders topic"
π Version History
v5.0.0 (Current β Core, Http, Kafka, Playwright, MCP)
- 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, Playwright)
- XUnitAssured.Playwright β New package for browser-based UI testing with fluent DSL
- Multiple locator strategies: CSS, ARIA roles, labels, test IDs, placeholders, text, title
- All interaction types: click, fill, check, hover, focus, select, press, type, drag, scroll
- Screenshot capture, tracing, and Playwright Inspector integration (
RecordAndPause()) - Codegen translator: converts Playwright Inspector output to XUnitAssured DSL
- XUnitAssured.Mcp β New MCP server for AI-assisted test generation
- 10 tools: Playwright translation (3), HTTP scaffolding (3), Kafka scaffolding (4)
- Integrates with GitHub Copilot Chat, VS Code, Claude Desktop, and any MCP client
- stdio transport for zero-config local usage
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
- GitHub: @andrewBezerra
