TerevintoSoftware.Integrator
0.0.2
dotnet tool install --global TerevintoSoftware.Integrator --version 0.0.2
dotnet new tool-manifest # if you are setting up this repo dotnet tool install --local TerevintoSoftware.Integrator --version 0.0.2
#tool dotnet:?package=TerevintoSoftware.Integrator&version=0.0.2
nuke :add-package TerevintoSoftware.Integrator --version 0.0.2
TerevintoSoftware.Integrator
This project aims to provide a way for c# developers to quickly create ASP.NET Core Integration Tests for an entire project at once.
This is meant to help people that have a solution without any tests to quickly get up and running, avoiding hours of writing repetitive boilerplate code.
This currently supports only NUnit (v3) tests, and it was tested with fairly simple/common scenarios (see the SampleLibrary folder).
Sample usage
- Install the tool:
dotnet tool install TerevintoSoftware.Integrator
- (optional) See the available options with
dotnet-integrator --help
- Run the generator:
dotnet-integrator --assembly "path-to-assembly" --output "path-to-output" --base-namespace YourLibrary.Tests
Considering an endpoint like:
[HttpGet("{id}/async-wrapped")]
public async Task<ActionResult<WeatherForecast>> GetWrappedAsync(int id)
{
}
The tool would generate a test like:
[Test]
public async Task Test_Get_GetWrappedAsync()
{
// Arrange
int id = default;
WeatherForecast expectedResult = default;
var httpClient = GetClient();
// Act
var requestUri = $"weather/{id}/async-wrapped";
var httpResult = await httpClient.GetAsync(requestUri);
// Assert
Assert.That(httpResult.IsSuccessStatusCode, Is.True);
var contentResult = await httpResult.Content.ReadFromJsonAsync<WeatherForecast>();
Assert.That(contentResult, Is.EqualTo(expectedResult));
}
See more examples in the Samples folder.
How to build
- Install Visual Studio 2022 (.NET 8 required), if needed.
- Install git, if needed.
- Clone this repository.
- Build from Visual Studio or through
dotnet build
.
Running tests
Once the solution is compiled, tests can be run either from Visual Studio's Test Explorer window, or through dotnet test
.
License
The .NET Tool and this solution are licensed under the MIT license.
Bug reports and feature requests
Please use the issue tracker and ensure your question/feedback was not previously reported.
Product | Versions 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. |
This package has no dependencies.
[0.0.2]: Improve URL handling, support generics, and fix some bugs.
[0.0.1]: Initial release.