ArwynFr.IntegrationTesting
0.1.0
See the version list below for details.
dotnet add package ArwynFr.IntegrationTesting --version 0.1.0
NuGet\Install-Package ArwynFr.IntegrationTesting -Version 0.1.0
<PackageReference Include="ArwynFr.IntegrationTesting" Version="0.1.0" />
paket add ArwynFr.IntegrationTesting --version 0.1.0
#r "nuget: ArwynFr.IntegrationTesting, 0.1.0"
// Install ArwynFr.IntegrationTesting as a Cake Addin #addin nuget:?package=ArwynFr.IntegrationTesting&version=0.1.0 // Install ArwynFr.IntegrationTesting as a Cake Tool #tool nuget:?package=ArwynFr.IntegrationTesting&version=0.1.0
ArwynFr.IntegrationTesting
This library provides utility classes for writing integration tests in
dotnet using XUnit
and WebApplicationFactory
.
Installation
dotnet add package ArwynFr.IntegrationTesting
Usage
Read advanced usage documentation for further details.
By default, the lib redirects the tested application logs to XUnit output, so you get them in the test output in case of failure. It also overwrites the application configuration with values from user secrets and environement variables.
public class MyTest : IntegrationTestBase<Program>
{
public MyTest(ITestOutputHelper output) : base(output) { }
[Fact]
public async Task OnTest()
{
// Call system under test
var response = await Client.GetFromJsonAsync<OrderDto>($"/order");
response.Should().HaveValue();
}
// Override a service with fake implementation in the tested app
protected override void ConfigureAppServices(IServiceCollection services)
=> services.AddSingleton<IMyService, FakeService>();
}
EntityFrameworkCore integration
public class TestBaseDb : IntegrationTestBase<Program, MyDbContext>
{
public TestBaseDb(ITestOutputHelper output) : base(output) { }
[Fact]
public async Task OnTest()
{
// Access the injected dbcontext
var value = await Database.Values
.Where(val => val.Id == 1)
.Select(val => val.Result)
.FirstOrDefaultAsync();
// Call system under test
var result = await Client.GetFromJsonAsync<int>("/api/value/1");
result.Should().Be(value + 1);
}
// Create and drop a database for every test execution
protected override IDatabaseTestStrategy<Context> DatabaseTestStrategy
=> IDatabaseTestStrategy<MyDbContext>.DatabasePerTest;
// Configure EFcore with a random database name
protected override void ConfigureDbContext(DbContextOptionsBuilder builder)
=> builder.UseSqlite($"Data Source={Guid.NewGuid()}.sqlite");
}
Contributing
This project welcomes contributions:
Request for support:
TBD
Disclose vulnerability:
Please create a new security advisory on GitHub
Report malfunctions:
Please create a new issue on GitHub
Suggest a feature:
Please create a new issue on GitHub
Offer some code:
Please fork the repository
and submit a pull-request
Read our definition of done in contributing guidelines
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. |
-
net8.0
- Microsoft.AspNetCore.Mvc.Testing (>= 8.0.1)
- Microsoft.EntityFrameworkCore.Relational (>= 8.0.1)
- Microsoft.Extensions.Configuration (>= 8.0.0)
- Microsoft.Extensions.DependencyInjection (>= 8.0.0)
- Microsoft.Extensions.Logging (>= 8.0.0)
- XUnit (>= 2.6.6)
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 |
---|---|---|
0.3.10 | 90 | 9/27/2024 |
0.3.9 | 85 | 9/25/2024 |
0.3.8 | 77 | 9/23/2024 |
0.3.7 | 127 | 9/16/2024 |
0.3.6 | 97 | 9/10/2024 |
0.3.5 | 98 | 9/9/2024 |
0.3.4 | 103 | 9/5/2024 |
0.3.3 | 126 | 8/23/2024 |
0.3.2 | 110 | 8/20/2024 |
0.3.1 | 117 | 8/17/2024 |
0.3.0 | 130 | 8/16/2024 |
0.2.41 | 106 | 8/16/2024 |
0.2.40 | 120 | 8/14/2024 |
0.2.39 | 118 | 8/13/2024 |
0.2.37 | 96 | 8/7/2024 |
0.2.35 | 92 | 7/9/2024 |
0.2.34 | 113 | 7/8/2024 |
0.2.33 | 101 | 6/26/2024 |
0.2.32 | 95 | 6/26/2024 |
0.2.31 | 98 | 6/18/2024 |
0.2.30 | 100 | 6/14/2024 |
0.2.29 | 81 | 6/7/2024 |
0.2.28 | 99 | 6/2/2024 |
0.2.27 | 83 | 5/22/2024 |
0.2.26 | 108 | 5/17/2024 |
0.2.25 | 96 | 5/16/2024 |
0.2.24 | 100 | 5/16/2024 |
0.2.23 | 106 | 5/15/2024 |
0.2.22 | 97 | 5/15/2024 |
0.2.21 | 93 | 5/15/2024 |
0.2.20 | 108 | 5/14/2024 |
0.2.19 | 86 | 5/13/2024 |
0.2.18 | 132 | 4/28/2024 |
0.2.17 | 99 | 4/24/2024 |
0.2.16 | 106 | 4/18/2024 |
0.2.15 | 87 | 4/17/2024 |
0.2.14 | 83 | 4/17/2024 |
0.2.12 | 98 | 4/12/2024 |
0.2.11 | 117 | 4/12/2024 |
0.2.10 | 119 | 4/10/2024 |
0.2.9 | 94 | 4/8/2024 |
0.2.8 | 99 | 4/8/2024 |
0.2.7 | 127 | 3/15/2024 |
0.2.6 | 128 | 3/15/2024 |
0.2.5 | 116 | 3/6/2024 |
0.2.4 | 118 | 2/24/2024 |
0.2.3 | 103 | 2/16/2024 |
0.2.2 | 119 | 2/14/2024 |
0.2.1 | 133 | 2/8/2024 |
0.2.0 | 113 | 2/2/2024 |
0.1.2 | 110 | 1/30/2024 |
0.1.1 | 110 | 1/30/2024 |
0.1.0 | 113 | 1/26/2024 |