Skip to content

Commit

Permalink
Changed all integration test categories to separate Website tests fro…
Browse files Browse the repository at this point in the history
…m API tests
  • Loading branch information
jezzsantos committed Apr 18, 2024
1 parent f7d2dc5 commit fa704f7
Show file tree
Hide file tree
Showing 38 changed files with 47 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: >
dotnet test --no-build --verbosity normal
--configuration ${{env.TESTINGONLY_BUILD_CONFIGURATION}}
--filter:"Category=Integration.Web" --collect:"XPlat Code Coverage" --results-directory:"src/TestResults/csharp"
--filter:"Category=Integration.API|Category=Integration.Website" --collect:"XPlat Code Coverage" --results-directory:"src/TestResults/csharp"
--logger:"trx"
--logger:"junit;LogFileName={assembly}.junit.xml;MethodFormat=Class;FailureBodyFormat=Verbose"
--test-adapter-path:. "${{env.SOLUTION_PATH}}"
Expand Down
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,8 @@ There are 3 flavors of build configuration: `Debug`, `Release` and `ReleaseForDe

* Run all the **unit** tests (`Category=Unit`)
* Run all the **architecture** tests (`Category=Unit.Architecture`)
* Run all the **integration** tests (`Category=Integration.Web`)
* Run all the **integration** tests (`Category=Integration.API`)
* Run all the **integration** tests (`Category=Integration.Website`)

> All automated tests must pass in GitHub Actions to submit changes to the codebase
Expand Down
8 changes: 4 additions & 4 deletions README_DERIVATIVE.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,15 @@ When pushed, all branches will be built and tested with GitHub actions

2. Run these tests:

In Rider, run all C# tests with Category= `Unit`, `Unit.Architecture` and `Integration.Web`
In Rider, run all C# tests with Category= `Unit`, `Unit.Architecture`, `Integration.API` and`Integration.Website`

> Note: Use `Group By > Category` in Rider's unit test explorer to view these three categories easily.

OR, in a terminal:

- `dotnet test --filter:"Category=Unit|Category=Unit.Architecture" src\SaaStack.sln`

- `dotnet test --filter:"Category=Integration.Web" src\SaaStack.sln`
- `dotnet test --filter:"Category=Integration.API|Category=Integration.Website" src\SaaStack.sln`

3. Configure your "Commit " window to select the "Cleanup with 'Full Cleanup' profile".

Expand Down Expand Up @@ -268,13 +268,13 @@ To kill these processes:
### Everyday tests
Run all C# tests with Category= `Unit`, `Unit.Architecture` and `Integration.Web`
Run all C# tests with Category= `Unit`, `Unit.Architecture`, `Integration.API` and `Integration.Website`
OR, in a terminal:
- `dotnet test --filter:"Category=Unit|Category=Unit.Architecture" src\SaaStack.sln`
- `dotnet test --filter:"Category=Integration.Web" src\SaaStack.sln`
- `dotnet test --filter:"Category=Integration.API|Category=Integration.Website" src\SaaStack.sln`
> Note: All tests will be run in parallel in `Rider` or in `dotnet test`.
Expand Down
4 changes: 2 additions & 2 deletions docs/design-principles/0020-api-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,12 @@ Then we use Roslyn analyzers (and other tooling) to guide the author in creating

6. You would then add a validation class to validate the inbound request (see next section)

7. Lastly, you would write an integration test to test that your API works in the test category: `Integration.Web`.
7. Lastly, you would write an integration test to test that your API works in the test category: `Integration.API`.

- For example, in the project and folder: `CarsApi.IntegrationTests/CarsApiSpec.cs`

```c#
[Trait("Category", "Integration.Web")] [Collection("API")]
[Trait("Category", "Integration.API")] [Collection("API")]
public class CarsApiSpec : WebApiSpecSetup<Program>
{
public CarsApiSpec(WebApplicationFactory<Program> factory) : base(factory)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace AncillaryInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class AuditsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace AncillaryInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class EmailsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace AncillaryInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class FeatureFlagsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace AncillaryInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class ProvisioningsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace AncillaryInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class RecordingApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace AncillaryInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class UsagesApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace BookingsInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class BookingsApiSpec : WebApiSpec<Program>
{
Expand Down
2 changes: 1 addition & 1 deletion src/CarsInfrastructure.IntegrationTests/CarsApiSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace CarsInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class CarsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace EndUsersInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class EndUsersApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace EndUsersInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class InvitationsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace IdentityInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class AuthTokensApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace IdentityInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class MachineCredentialsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace IdentityInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class PasswordCredentialsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace IdentityInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class SingleSignOnApiSpec : WebApiSpec<Program>
{
Expand Down
2 changes: 1 addition & 1 deletion src/ImagesInfrastructure.IntegrationTests/ImagesApiSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ImagesInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class ImagesApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class AuthNApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class AuthZApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class ContentNegotiationApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class DataFormatsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class DefaultStatusCodeApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class ErrorApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class HealthCheckApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class MultiTenancySpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Infrastructure.Web.Api.IntegrationTests;
[UsedImplicitly]
public class RequestCorrelationApiSpec
{
[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class GivenAnHttpClient : WebApiSpec<Program>
{
Expand Down Expand Up @@ -65,7 +65,7 @@ public async Task WhenGetWithXCorrelationId_ThenReturnsSameResponseHeader()
}
}

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class GivenAJsonClient : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Infrastructure.Web.Api.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class ValidationApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Infrastructure.Web.Website.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class AuthNApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Infrastructure.Web.Website.IntegrationTests;
[UsedImplicitly]
public class CSRFApiSpec
{
[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class GivenNoContext : WebApiSpec<Program>
{
Expand Down Expand Up @@ -61,7 +61,7 @@ public async Task WhenRequestWebRoot_ThenReturnsIndexHtml()
}
}

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class GivenAnInsecureGetRequest : WebApiSpec<Program>
{
Expand Down Expand Up @@ -115,7 +115,7 @@ public async Task WhenRequestedForUserWithCSRFToken_ThenSucceeds()
}
}

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class GivenAnInsecurePostRequestByAnonymousUser : WebApiSpec<Program>
{
Expand Down Expand Up @@ -226,7 +226,7 @@ public async Task WhenRequestedWithUserCSRFToken_ThenForbidden()
}
}

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class GivenAnInsecurePostRequestByAuthenticatedUser : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Infrastructure.Web.Website.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class FeatureFlagsApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Infrastructure.Web.Website.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class HealthCheckApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Infrastructure.Web.Website.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class RecordingApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Infrastructure.Web.Website.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.Website")]
[Collection("API")]
public class ReverseProxyApiSpec : WebApiSpec<Program>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace OrganizationsInfrastructure.IntegrationTests;

[Trait("Category", "Integration.Web")]
[Trait("Category", "Integration.API")]
[Collection("API")]
public class OrganizationsApiSpec : WebApiSpec<Program>
{
Expand Down
Loading

0 comments on commit fa704f7

Please sign in to comment.