testwire 0.2.1

dotnet tool install --global testwire --version 0.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local testwire --version 0.2.1
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=testwire&version=0.2.1
                    
nuke :add-package testwire --version 0.2.1
                    

<div align="center">

🔌 TestWire

NuGet License: MIT .NET

</div>


I built TestWire because once I finish a controller and need to write tests, if they're straightforward I just get bored writing them. I needed something that gives me a template based on my actual controller — not generic stubs, but ones shaped around my specific endpoints and dependencies. So TestWire reads your controller and generates test stubs based on it. You still write the real logic, it just handles the part that's purely mechanical.


What Gets Generated

For every controller TestWire finds, it produces a complete test project with:

  • Integration tests — using WebApplicationFactory<Program> for real HTTP calls
  • Happy path — a 200 OK / 201 Created test that validates the response body
  • Auth test — a 401 Unauthorized test when [Authorize] is present
  • Auto-generated .csproj — includes all necessary NuGet packages for xUnit or NUnit
  • Complex DTO support — generated request objects handle nested properties and collections
  • Query & Header analysis[FromQuery] and [FromHeader] parameters are detected and integrated into tests
// Your controller (SampleApi/Controllers/ProductsController.cs)
[ApiController]
[Route("api/[controller]")]
public class ProductsController : ControllerBase
{
    private readonly IProductService _service;

    public ProductsController(IProductService service)
    {
        _service = service;
    }

    [HttpGet("{id}")]
    public async Task<ActionResult<ProductDto>> GetById(int id) { ... }
}
// Generated by TestWire (xUnit example)
public class ProductsControllerTests : IClassFixture<WebApplicationFactory<Program>>
{
    private readonly HttpClient _client;

    public ProductsControllerTests(WebApplicationFactory<Program> factory)
    {
        _client = factory.CreateClient();
    }

    [Fact]
    public async Task GetById_Returns200_WithProductDto()
    {
        var response = await _client.GetAsync("api/products/1");
        response.EnsureSuccessStatusCode();
        
        var result = await response.Content.ReadFromJsonAsync<ProductDto>();
        Assert.NotNull(result);
    }
}

Installation

Requires .NET 8+

dotnet tool install -g testwire

Usage

Basic

testwire generate --project ./MyApi/MyApi.csproj

Scans your project and writes a full test project to ./MyApi.Tests/ by default.

Custom output directory

testwire generate --project ./MyApi/MyApi.csproj --output ./tests

Preview without writing files

testwire generate --project ./MyApi/MyApi.csproj --dry-run

Use NUnit instead of xUnit

testwire generate --project ./MyApi/MyApi.csproj --framework nunit

All Options

Flag Description Default
--project Path to the .csproj file (required)
--output Directory to write generated test files {ProjectName}.Tests
--framework Test framework: xunit or nunit xunit
--dry-run Print output to console, don't write files false
--report Generate a testwire-report.md summary false

Changelog

See CHANGELOG.md for the full history of changes.


Current Limitations (v0.2.0)

This is an early release. Here's what's not supported yet:

  • No --controller flag to target a single controller
  • Mocking for internal service calls within integration tests (coming in v0.3)

If any of these block you, please open an issue.


Contributing

PRs and issues are welcome. Open an issue to discuss what you'd like to change before submitting a PR.


License

MIT © Mazen Hassan

Product Compatible and additional computed target framework versions.
.NET 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 was computed.  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 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
0.2.1 41 6/7/2026
0.2.0 51 6/7/2026
0.1.2 97 5/31/2026
0.1.1 97 5/27/2026
0.1.0 96 5/26/2026