Skip to content

Commit

Permalink
Update integration tests docs to match xUnit v3
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubfijalkowski committed Dec 30, 2024
1 parent 16ee240 commit 3301f2d
Showing 1 changed file with 8 additions and 17 deletions.
25 changes: 8 additions & 17 deletions docs/tests/integration_tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public class ExampleAppTestApp : LeanCodeTestFactory<Startup>
{
base.ConfigureWebHost(builder);

// Remember to set correct content root path. This is the easiest option.
builder.UseSolutionRelativeContentRoot(
"tests/ExampleApp.IntegrationTests/ExampleApp.IntegrationTests.csproj");

builder.ConfigureServices(services =>
{
// Incorporate a hosted service responsible for creating
Expand All @@ -78,19 +82,6 @@ public class ExampleAppTestApp : LeanCodeTestFactory<Startup>
}
```

Following `ItemGroup` must be added to the integration test project's `.csproj` file. This group facilitates the discovery of the content root for the web application being tested.

```xml
<ItemGroup>
<WebApplicationFactoryContentRootAttribute
Include="ExampleApp.IntegrationTests"
AssemblyName="ExampleApp.IntegrationTests"
ContentRootPath="$(MSBuildProjectDirectory)"
ContentRootTest="ExampleApp.IntegrationTests.csproj"
Priority="-1" />
</ItemGroup>
```

## Authentication handler

The `TestAuthenticationHandler` manages user authentication and deserialization of `ClaimsPrincipal` objects for testing purposes.
Expand Down Expand Up @@ -185,7 +176,7 @@ public class AuthenticatedExampleAppTestApp : ExampleAppTestApp

public AuthenticatedExampleAppTestApp() { }

public override async Task InitializeAsync()
public override async ValueTask InitializeAsync()
{
AuthenticateAsTestSuperUser();

Expand Down Expand Up @@ -241,7 +232,7 @@ public class UnauthenticatedExampleAppTestApp : ExampleAppTestApp
public HttpCommandsExecutor Command { get; private set; } = default!;
public HttpOperationsExecutor Operation { get; private set; } = default!;

public override async Task InitializeAsync()
public override async ValueTaskTask InitializeAsync()
{
await base.InitializeAsync();

Expand Down Expand Up @@ -294,9 +285,9 @@ public class Tests : IAsyncLifetime
Assert.Matches("^project_[0-7][0-9A-HJKMNP-TV-Z]{25}$", project.Id);
}

public Task InitializeAsync() => app.InitializeAsync();
public ValueTask InitializeAsync() => app.InitializeAsync();

public Task DisposeAsync() => app.DisposeAsync().AsTask();
public ValueTask DisposeAsync() => app.DisposeAsync();
}

public static class ApiClientHelpers
Expand Down

0 comments on commit 3301f2d

Please sign in to comment.