Skip to content

Commit dd42199

Browse files
authored
Add GitHub CTRF test reporting (#445)
1 parent 52ea219 commit dd42199

File tree

5 files changed

+48
-11
lines changed

5 files changed

+48
-11
lines changed

.github/workflows/pull-request.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,15 @@ jobs:
4040
path: artifacts/test
4141
compression-level: 9
4242
if: always()
43+
44+
- name: Publish Test Report
45+
uses: ctrf-io/github-test-reporter@v1
46+
with:
47+
report-path: './artifacts/test/*.ctrf'
48+
summary-report: true
49+
github-report: true
50+
pull-request: true
51+
update-comment: true
52+
env:
53+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54+
if: always()

.github/workflows/push-main.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ jobs:
6060
path: artifacts/packages
6161
compression-level: 0
6262
if: always()
63+
64+
- name: Publish Test Report
65+
uses: ctrf-io/github-test-reporter@v1
66+
with:
67+
report-path: './artifacts/test/*.ctrf'
68+
summary-report: true
69+
github-report: true
70+
if: always()

test/test.v3/Tests.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ public class Tests
55
[Fact]
66
public void Passing() { }
77

8-
[Fact(Explicit = true)]
9-
public void Failing() => Assert.Fail("This is a failing test");
8+
[Fact(Skip = "Unconditionally skipped")]
9+
public void Skipped() => Assert.Fail("This does not run");
1010

11-
[Theory]
12-
[InlineData(true, Explicit = true)]
13-
[InlineData(false)]
14-
public void ConditionalSkip(bool value) => Assert.SkipWhen(value, "Conditionally skipped");
11+
[Fact(Explicit = true)]
12+
public void Explicit() => Assert.Fail("This only runs explicitly.");
1513
}

tools/builder/targets/TestCore.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,20 @@ public class TestCore
1212
{
1313
public static async Task OnExecute(BuildContext context)
1414
{
15-
context.BuildStep("Running .NET Core tests");
15+
context.BuildStep("Running .NET tests");
1616

1717
Directory.CreateDirectory(context.TestOutputFolder);
18-
File.Delete(Path.Combine(context.TestOutputFolder, "test.xunit.runner.visualstudio-netcore.trx"));
1918

20-
await context.Exec("dotnet", $"test test/test.xunit.runner.visualstudio -tl:off --configuration {context.Configuration} --no-build --framework net8.0 --logger trx;LogFileName=test.xunit.runner.visualstudio-netcore.trx --results-directory \"{context.TestOutputFolder}\" --verbosity {context.Verbosity}");
19+
var testFolder = Path.Combine(context.BaseFolder, "test", "test.xunit.runner.visualstudio", "bin", context.ConfigurationText, "net8.0");
20+
var testPath = Path.Combine(testFolder, "test.xunit.runner.visualstudio.dll");
21+
var reportPath = Path.Combine(context.TestOutputFolder, "test.xunit.runner.visualstudio-netcore.ctrf");
22+
File.Delete(reportPath);
23+
24+
await context.Exec("dotnet", $"exec {testPath} -ctrf {reportPath}");
25+
26+
context.BuildStep("Running .NET VSTest integration tests");
27+
28+
await context.Exec("dotnet", $"test test/test.v3 -tl:off --configuration {context.Configuration} --no-build --framework net8.0 --verbosity {context.Verbosity}");
2129
await context.Exec("dotnet", $"test test/test.v2 -tl:off --configuration {context.Configuration} --no-build --framework net8.0 --verbosity {context.Verbosity}");
2230
}
2331
}

tools/builder/targets/TestFx.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,20 @@ public static async Task OnExecute(BuildContext context)
1515
context.BuildStep("Running .NET Framework tests");
1616

1717
Directory.CreateDirectory(context.TestOutputFolder);
18-
File.Delete(Path.Combine(context.TestOutputFolder, "test.xunit.runner.visualstudio-netfx.trx"));
1918

20-
await context.Exec("dotnet", $"test test/test.xunit.runner.visualstudio -tl:off --configuration {context.Configuration} --no-build --framework net472 --logger trx;LogFileName=test.xunit.runner.visualstudio-netfx.trx --results-directory \"{context.TestOutputFolder}\" --verbosity {context.Verbosity}");
19+
var testFolder = Path.Combine(context.BaseFolder, "test", "test.xunit.runner.visualstudio", "bin", context.ConfigurationText, "net472");
20+
var testPath = Path.Combine(testFolder, "test.xunit.runner.visualstudio.exe");
21+
var reportPath = Path.Combine(context.TestOutputFolder, "test.xunit.runner.visualstudio-netfx.ctrf");
22+
File.Delete(reportPath);
23+
24+
await context.Exec(testPath, $"-ctrf {reportPath}", testFolder);
25+
26+
if (context.NeedMono)
27+
return;
28+
29+
context.BuildStep("Running .NET Framework VSTest integration tests");
30+
31+
await context.Exec("dotnet", $"test test/test.v3 -tl:off --configuration {context.Configuration} --no-build --framework net472 --verbosity {context.Verbosity}");
2132
await context.Exec("dotnet", $"test test/test.v2 -tl:off --configuration {context.Configuration} --no-build --framework net472 --verbosity {context.Verbosity}");
2233
await context.Exec("dotnet", $"test test/test.v1 -tl:off --configuration {context.Configuration} --no-build --framework net472 --verbosity {context.Verbosity}");
2334
}

0 commit comments

Comments
 (0)