Skip to content

Commit 01a24c0

Browse files
authored
upload test results to appveyor (#51)
* upload test results to appveyor * better test names * more cake
1 parent cfe154b commit 01a24c0

File tree

3 files changed

+21
-10
lines changed

3 files changed

+21
-10
lines changed

appveyor.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ init:
44

55
# Build script
66
build_script:
7-
- ps: .\build.ps1
7+
- ps: .\build.ps1 -Target AppVeyor
88

99
# Tests
1010
test: off
@@ -16,11 +16,6 @@ branches:
1616
- master
1717
- /feature/.*/
1818

19-
# Artifacts
20-
artifacts:
21-
- path: ./artifacts/FluentAssertions.Analyzers*.nupkg
22-
name: Artifacts
23-
2419
# Build cache
2520
cache:
2621
- tools -> build.cake

build.cake

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ var testCsproj = File("./src/FluentAssertions.Analyzers.Tests/FluentAssertions.A
1818
var nuspecFile = File("./src/FluentAssertions.Analyzers/FluentAssertions.Analyzers.nuspec");
1919
var version = GetCurrentVersion(Context);
2020

21+
var testResults = MakeAbsolute(buildDir + File("./testResults.trx"));
22+
2123
//////////////////////////////////////////////////////////////////////
2224
// TASKS
2325
//////////////////////////////////////////////////////////////////////
@@ -62,7 +64,8 @@ Task("Run-Unit-Tests")
6264
DotNetCoreTest(testCsproj, new DotNetCoreTestSettings
6365
{
6466
Filter = "TestCategory=Completed",
65-
Configuration = configuration
67+
Configuration = configuration,
68+
ArgumentCustomization = builder => builder.Append($"--logger \"trx;LogFileName={testResults}\"")
6669
});
6770
});
6871

@@ -96,12 +99,25 @@ Task("Publish-NuGet")
9699
});
97100
});
98101

102+
Task("AppVeyor")
103+
.IsDependentOn("Update-Version")
104+
.IsDependentOn("Run-Unit-Tests")
105+
.IsDependentOn("Pack")
106+
.WithCriteria(AppVeyor.IsRunningOnAppVeyor)
107+
.Does(() =>
108+
{
109+
AppVeyor.UploadTestResults(testResults, AppVeyorTestResultsType.MSTest);
110+
111+
var nugetPackage = MakeAbsolute(buildDir + File($"./FluentAssertions.Analyzers.{version}.nupkg"));
112+
AppVeyor.UploadArtifact(nugetPackage, new AppVeyorUploadArtifactsSettings()
113+
.SetArtifactType(AppVeyorUploadArtifactType.NuGetPackage));
114+
});
115+
99116
//////////////////////////////////////////////////////////////////////
100117
// TASK TARGETS
101118
//////////////////////////////////////////////////////////////////////
102119

103120
Task("Default")
104-
.IsDependentOn("Update-Version")
105121
.IsDependentOn("Build")
106122
.IsDependentOn("Run-Unit-Tests")
107123
.IsDependentOn("Pack");

src/FluentAssertions.Analyzers.Tests/TestAttributes.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public override TestResult[] Execute(ITestMethod testMethod)
6969
foreach (var assertion in GetTestCases(diagnosticAttribute))
7070
{
7171
var result = testMethod.Invoke(new[] { assertion });
72-
result.DisplayName = assertion;
72+
result.DisplayName = $"{testMethod.TestMethodName} (\"{assertion}\")";
7373

7474
results.Add(result);
7575
}
@@ -79,7 +79,7 @@ public override TestResult[] Execute(ITestMethod testMethod)
7979
foreach (var (oldAssertion, newAssertion) in GetTestCases(codeFixAttribute))
8080
{
8181
var result = testMethod.Invoke(new[] { oldAssertion, newAssertion });
82-
result.DisplayName = $"{Environment.NewLine}old: \"{oldAssertion}\" {Environment.NewLine}new: \"{newAssertion}\"";
82+
result.DisplayName = $"{testMethod.TestMethodName} ({Environment.NewLine}old: \"{oldAssertion}\" {Environment.NewLine}new: \"{newAssertion}\")";
8383

8484
results.Add(result);
8585
}

0 commit comments

Comments
 (0)