Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
run: dotnet build --no-restore --configuration Release /p:TreatWarningsAsErrors=true

- name: Run tests
run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
run: dotnet test --no-build --configuration Release --verbosity normal --results-directory ./coverage --coverage --coverage-output-format cobertura

- name: Stop SonarQube
env:
Expand All @@ -99,7 +99,7 @@ jobs:
- name: Upload coverage reports
uses: codecov/codecov-action@v5
with:
files: ./coverage/**/coverage.cobertura.xml
files: ./coverage/**/*.cobertura.xml
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
4 changes: 2 additions & 2 deletions .github/workflows/pr-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
run: dotnet build --no-restore --configuration Release /p:TreatWarningsAsErrors=true

- name: Run tests
run: dotnet test --no-build --configuration Release --verbosity normal --collect:"XPlat Code Coverage" --results-directory ./coverage
run: dotnet test --no-build --configuration Release --verbosity normal --results-directory ./coverage --coverage --coverage-output-format cobertura

- name: Stop SonarQube
env:
Expand All @@ -120,7 +120,7 @@ jobs:
- name: Upload coverage reports
uses: codecov/codecov-action@v5
with:
files: ./coverage/**/coverage.cobertura.xml
files: ./coverage/**/*.cobertura.xml
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: true
58 changes: 58 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,64 @@ internal async Task MyTest(
- Combine both: use `[AutoNSubstituteData]` with `[Frozen]` to inject configured mocks from a manual
fixture

# Test Commands

Task wrappers (recommended):

```bash
task test:all # dotnet test (Release)
task test:verbose # dotnet test (detailed logs)
task test:coverage # dotnet test + coverage
task test:watch # dotnet watch ... test
```

Direct `dotnet` commands:
```bash
# Run the full test suite (solution-level)
DOTNET_NOLOGO=1 dotnet test --configuration Release

# Faster inner loop: run a single target framework (projects are multi-targeted)
DOTNET_NOLOGO=1 dotnet test --configuration Release -f net10.0

# Run a single test project
DOTNET_NOLOGO=1 dotnet test \
--project tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj \
--configuration Release -f net10.0

# Verbose output for debugging
DOTNET_NOLOGO=1 dotnet test --configuration Release --logger "console;verbosity=detailed"
```

Run a single test (xUnit v3 + Microsoft.Testing.Platform)

This repo pins the test runner in `global.json`:

```json
"test": {"runner": "Microsoft.Testing.Platform"}
```

```bash
# list tests (copy fully-qualified name)
DOTNET_NOLOGO=1 dotnet test \
--project tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj \
-f net10.0 -v q \
--list-tests --no-progress --no-ansi

# run one test method
DOTNET_NOLOGO=1 dotnet test \
--project tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj \
-f net10.0 -v q \
--filter-method "MyNamespace.MyTestClass.MyTestMethod" \
--minimum-expected-tests 1 \
--no-progress --no-ansi

# handy filters
DOTNET_NOLOGO=1 dotnet test --project tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj -f net10.0 -v q \
--filter-class "MyNamespace.MyTestClass" --minimum-expected-tests 1 --no-progress --no-ansi
DOTNET_NOLOGO=1 dotnet test --project tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj -f net10.0 -v q \
--filter-namespace "MyNamespace.Tests" --minimum-expected-tests 1 --no-progress --no-ansi
```

# C# 14 Extension Members - Valid Syntax

## This is VALID C# 14 syntax - do NOT change it
Expand Down
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,8 @@ dotnet test tests/MinimalLambda.UnitTests
# Run with verbose output
dotnet test --verbosity detailed

# Run with coverage (if configured)
dotnet test /p:CollectCoverage=true
# Run with coverage (MTP)
dotnet test --coverage --coverage-output-format cobertura
```

### Test Requirements
Expand Down
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
<PackageVersion Include="coverlet.collector" Version="6.0.4" />
<PackageVersion Include="JetBrains.Annotations" Version="2025.2.4" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.0.4" />
<PackageVersion Include="System.Formats.Asn1" Version="6.0.1" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
Expand Down
7 changes: 5 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{
"sdk": {
"rollForward": "latestMinor",
"version": "10.0.102"
"version": "10.0.101"
},
"test": {
"runner": "Microsoft.Testing.Platform"
}
}
}
6 changes: 6 additions & 0 deletions opencode.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://opencode.ai/config.json",
"permission": {
"git": "ask"
}
}
7 changes: 7 additions & 0 deletions src/MinimalLambda.Testing/LambdaApplicationFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,13 @@ private void ConfigureHostBuilder(
if (string.IsNullOrEmpty(options.BootstrapOptions.RuntimeApiEndpoint))
options.BootstrapOptions.RuntimeApiEndpoint = "localhost";
});

services.PostConfigure<HostOptions>(options =>
{
var minShutdownTimeout = TimeSpan.FromSeconds(30);
if (options.ShutdownTimeout < minShutdownTimeout)
options.ShutdownTimeout = minShutdownTimeout;
});
});

// Build the host but DON'T start it - server will start it
Expand Down
6 changes: 3 additions & 3 deletions tasks/TestTasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ tasks:
silent: true
cmds:
- echo "πŸ§ͺ Running unit tests"
- dotnet test --configuration Release --filter "Category=Unit" --no-build
- dotnet test --configuration Release --filter-trait "Category=Unit" --no-build
- echo "βœ… Unit tests completed!"

coverage:
desc: Run tests with code coverage collection
silent: true
cmds:
- echo "πŸ“Š Running tests with coverage collection"
- dotnet test --configuration Release --collect:"XPlat Code Coverage" --no-build
- dotnet test --configuration Release --coverage --coverage-output-format cobertura --no-build
- echo "βœ… Coverage collection completed!"

watch:
desc: Run tests in watch mode for TDD
silent: true
cmds:
- echo "πŸ‘€ Starting test watch mode"
- dotnet watch --project tests/MinimalLambda.Tests test --configuration Release
- dotnet watch --project tests/MinimalLambda.UnitTests test --configuration Release

verbose:
desc: Run tests with detailed output for debugging
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
Expand All @@ -17,6 +17,7 @@
<PackageReference Include="AutoFixture" />
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="NSubstitute.Analyzers.CSharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net9.0;net10.0</TargetFrameworks>
<LangVersion>preview</LangVersion>
Expand Down Expand Up @@ -26,6 +26,7 @@
<PackageReference Include="AutoFixture" />
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.Testing" />
<PackageReference Include="NSubstitute.Analyzers.CSharp">
<PrivateAssets>all</PrivateAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
Expand All @@ -18,6 +18,7 @@
<PackageReference Include="Basic.Reference.Assemblies.Net80" />
<PackageReference Include="Basic.Reference.Assemblies.Net90" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="JetBrains.Annotations" />
<PackageReference Include="Microsoft.CodeAnalysis" />
<PackageReference Include="Microsoft.CodeAnalysis.Common" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
Expand All @@ -23,6 +23,7 @@
<PackageReference Include="AutoFixture" />
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="AutoFixture.AutoNSubstitute" />
<PackageReference Include="NSubstitute.Analyzers.CSharp">
<PrivateAssets>all</PrivateAssets>
Expand Down
3 changes: 2 additions & 1 deletion tests/MinimalLambda.UnitTests/MinimalLambda.UnitTests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ο»Ώ<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down Expand Up @@ -33,6 +33,7 @@
<PackageReference Include="AwesomeAssertions" />
<PackageReference Include="AutoFixture" />
<PackageReference Include="coverlet.collector" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" />
<PackageReference Include="NSubstitute.Analyzers.CSharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Loading