Skip to content

Commit b78fc59

Browse files
committed
Merge remote-tracking branch 'origin/master' into memberMutantSupport
2 parents 0cd64fa + 7461da8 commit b78fc59

37 files changed

+324
-7810
lines changed

.editorconfig

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
9696

9797
csharp_style_throw_expression = true:suggestion
9898

99-
csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
99+
# csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion
100+
# Disable IDE0058: Not relevant to fluent api
101+
dotnet_diagnostic.IDE0058.severity = none
100102
csharp_style_unused_value_assignment_preference = discard_variable:suggestion
101103

102104
csharp_style_var_for_built_in_types = true:suggestion

azure-pipelines.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,18 +199,7 @@ stages:
199199
command: test
200200
projects: '**/Validation.csproj'
201201
arguments: --filter Category=SingleTestProject
202-
203-
- template: pipeline-templates/run-integration-test-steps.yml
204-
parameters:
205-
testName: 'windows-fsharp'
206-
workingDirectory: 'integrationtest/TargetProjects/NetCore/Library.FSharp.XUnit'
207-
- task: DotNetCoreCLI@2
208-
displayName: 'Assert integration test results'
209-
inputs:
210-
command: test
211-
projects: '**/Validation.csproj'
212-
arguments: --filter Category=FSharp
213-
202+
214203
- job: LinuxTests
215204
displayName: Run tests on Linux
216205
pool:

integrationtest/Validation/ValidationProject/ValidateStrykerResults.cs

Lines changed: 122 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -11,68 +11,49 @@
1111
using Stryker.Core.Reporters.Json;
1212
using Xunit;
1313

14-
namespace IntegrationTests
15-
{
16-
public class ValidateStrykerResults
17-
{
18-
private readonly ReadOnlyCollection<SyntaxKind> _blacklistedSyntaxKindsForMutating =
19-
new(new[]
20-
{
21-
// Usings
22-
SyntaxKind.UsingDirective,
23-
SyntaxKind.UsingKeyword,
24-
SyntaxKind.UsingStatement,
25-
// Comments
26-
SyntaxKind.DocumentationCommentExteriorTrivia,
27-
SyntaxKind.EndOfDocumentationCommentToken,
28-
SyntaxKind.MultiLineCommentTrivia,
29-
SyntaxKind.MultiLineDocumentationCommentTrivia,
30-
SyntaxKind.SingleLineCommentTrivia,
31-
SyntaxKind.SingleLineDocumentationCommentTrivia,
32-
SyntaxKind.XmlComment,
33-
SyntaxKind.XmlCommentEndToken,
34-
SyntaxKind.XmlCommentStartToken,
35-
}
36-
);
37-
private readonly ReadOnlyCollection<SyntaxKind> _parentSyntaxKindsForMutating =
38-
new(new[]
39-
{
40-
SyntaxKind.MethodDeclaration,
41-
SyntaxKind.PropertyDeclaration,
42-
SyntaxKind.ConstructorDeclaration,
43-
SyntaxKind.FieldDeclaration,
44-
SyntaxKind.OperatorDeclaration,
45-
SyntaxKind.IndexerDeclaration,
46-
}
47-
);
48-
private const string MutationReportJson = "mutation-report.json";
14+
namespace Validation;
4915

50-
[Fact]
51-
[Trait("Category", "SingleTestProject")]
52-
public async Task CSharp_NetFramework_SingleTestProject()
16+
public class ValidateStrykerResults
17+
{
18+
private readonly ReadOnlyCollection<SyntaxKind> _blacklistedSyntaxKindsForMutating =
19+
new(new[]
5320
{
54-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
55-
{
56-
var directory = new DirectoryInfo("../../../../../TargetProjects/NetFramework/FullFrameworkApp.Test/StrykerOutput");
57-
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
58-
59-
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
60-
.OrderByDescending(f => f.LastWriteTime)
61-
.First();
62-
63-
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
64-
65-
var report = await JsonReportSerialization.DeserializeJsonReportAsync(strykerRunOutput);
66-
67-
CheckReportMutants(report, total: 29, ignored: 7, survived: 3, killed: 7, timeout: 0, nocoverage: 11);
68-
}
21+
// Usings
22+
SyntaxKind.UsingDirective,
23+
SyntaxKind.UsingKeyword,
24+
SyntaxKind.UsingStatement,
25+
// Comments
26+
SyntaxKind.DocumentationCommentExteriorTrivia,
27+
SyntaxKind.EndOfDocumentationCommentToken,
28+
SyntaxKind.MultiLineCommentTrivia,
29+
SyntaxKind.MultiLineDocumentationCommentTrivia,
30+
SyntaxKind.SingleLineCommentTrivia,
31+
SyntaxKind.SingleLineDocumentationCommentTrivia,
32+
SyntaxKind.XmlComment,
33+
SyntaxKind.XmlCommentEndToken,
34+
SyntaxKind.XmlCommentStartToken,
6935
}
36+
);
37+
private readonly ReadOnlyCollection<SyntaxKind> _parentSyntaxKindsForMutating =
38+
new(new[]
39+
{
40+
SyntaxKind.MethodDeclaration,
41+
SyntaxKind.PropertyDeclaration,
42+
SyntaxKind.ConstructorDeclaration,
43+
SyntaxKind.FieldDeclaration,
44+
SyntaxKind.OperatorDeclaration,
45+
SyntaxKind.IndexerDeclaration,
46+
}
47+
);
48+
private const string MutationReportJson = "mutation-report.json";
7049

71-
[Fact]
72-
[Trait("Category", "SingleTestProject")]
73-
public async Task CSharp_NetCore_SingleTestProject()
50+
[Fact]
51+
[Trait("Category", "SingleTestProject")]
52+
public async Task CSharp_NetFramework_SingleTestProject()
53+
{
54+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
7455
{
75-
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/NetCoreTestProject.XUnit/StrykerOutput");
56+
var directory = new DirectoryInfo("../../../../../TargetProjects/NetFramework/FullFrameworkApp.Test/StrykerOutput");
7657
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
7758

7859
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
@@ -81,116 +62,114 @@ public async Task CSharp_NetCore_SingleTestProject()
8162

8263
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
8364

84-
var report = await JsonReportSerialization.DeserializeJsonReportAsync(strykerRunOutput);
65+
var report = await strykerRunOutput.DeserializeJsonReportAsync();
8566

86-
CheckReportMutants(report, total: 601, ignored: 247, survived: 4, killed: 9, timeout: 2, nocoverage: 308);
87-
CheckReportTestCounts(report, total: 11);
67+
CheckReportMutants(report, total: 29, ignored: 7, survived: 3, killed: 7, timeout: 0, nocoverage: 11);
8868
}
69+
}
8970

90-
[Fact]
91-
[Trait("Category", "FSharp")]
92-
public async Task FSharp_SingleTestProject()
93-
{
94-
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/Library.FSharp.XUnit/StrykerOutput");
95-
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
71+
[Fact]
72+
[Trait("Category", "SingleTestProject")]
73+
public async Task CSharp_NetCore_SingleTestProject()
74+
{
75+
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/NetCoreTestProject.XUnit/StrykerOutput");
76+
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
9677

97-
var latestReport = directory
98-
.GetFiles(MutationReportJson, SearchOption.AllDirectories)
99-
.OrderByDescending(f => f.LastWriteTime)
100-
.First();
78+
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
79+
.OrderByDescending(f => f.LastWriteTime)
80+
.First();
10181

102-
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
82+
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
10383

104-
var report = await JsonReportSerialization.DeserializeJsonReportAsync(strykerRunOutput);
84+
var report = await strykerRunOutput.DeserializeJsonReportAsync();
10585

106-
CheckReportMutants(report, total: 0, ignored: 0, survived: 0, killed: 0, timeout: 0, nocoverage: 0);
107-
CheckReportTestCounts(report, total: 0);
108-
}
86+
CheckReportMutants(report, total: 601, ignored: 247, survived: 4, killed: 9, timeout: 2, nocoverage: 308);
87+
CheckReportTestCounts(report, total: 11);
88+
}
10989

110-
[Fact]
111-
[Trait("Category", "MultipleTestProjects")]
112-
public async Task CSharp_NetCore_WithTwoTestProjects()
113-
{
114-
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/Targetproject/StrykerOutput");
115-
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
90+
[Fact]
91+
[Trait("Category", "MultipleTestProjects")]
92+
public async Task CSharp_NetCore_WithTwoTestProjects()
93+
{
94+
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/Targetproject/StrykerOutput");
95+
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
11696

117-
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
118-
.OrderByDescending(f => f.LastWriteTime)
119-
.First();
97+
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
98+
.OrderByDescending(f => f.LastWriteTime)
99+
.First();
120100

121-
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
101+
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
122102

123-
var report = await JsonReportSerialization.DeserializeJsonReportAsync(strykerRunOutput);
103+
var report = await strykerRunOutput.DeserializeJsonReportAsync();
124104

125-
CheckReportMutants(report, total: 601, ignored: 105, survived: 5, killed: 11, timeout: 2, nocoverage: 447);
126-
CheckReportTestCounts(report, total: 21);
127-
}
105+
CheckReportMutants(report, total: 601, ignored: 105, survived: 5, killed: 11, timeout: 2, nocoverage: 447);
106+
CheckReportTestCounts(report, total: 21);
107+
}
128108

129-
[Fact]
130-
[Trait("Category", "Solution")]
131-
public async Task CSharp_NetCore_SolutionRun()
132-
{
133-
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/StrykerOutput");
134-
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
109+
[Fact]
110+
[Trait("Category", "Solution")]
111+
public async Task CSharp_NetCore_SolutionRun()
112+
{
113+
var directory = new DirectoryInfo("../../../../../TargetProjects/NetCore/StrykerOutput");
114+
directory.GetFiles("*.json", SearchOption.AllDirectories).ShouldNotBeEmpty("No reports available to assert");
135115

136-
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
137-
.OrderByDescending(f => f.LastWriteTime)
138-
.First();
116+
var latestReport = directory.GetFiles(MutationReportJson, SearchOption.AllDirectories)
117+
.OrderByDescending(f => f.LastWriteTime)
118+
.First();
139119

140-
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
120+
using var strykerRunOutput = File.OpenRead(latestReport.FullName);
141121

142-
var report = await JsonReportSerialization.DeserializeJsonReportAsync(strykerRunOutput);
122+
var report = await strykerRunOutput.DeserializeJsonReportAsync();
143123

144-
CheckReportMutants(report, total: 601, ignored: 247, survived: 4, killed: 9, timeout: 2, nocoverage: 308);
145-
CheckReportTestCounts(report, total: 23);
146-
}
124+
CheckReportMutants(report, total: 601, ignored: 247, survived: 4, killed: 9, timeout: 2, nocoverage: 308);
125+
CheckReportTestCounts(report, total: 23);
126+
}
147127

148-
private void CheckMutationKindsValidity(IJsonReport report)
128+
private void CheckMutationKindsValidity(IJsonReport report)
129+
{
130+
foreach (var file in report.Files)
149131
{
150-
foreach (var file in report.Files)
132+
var syntaxTreeRootNode = CSharpSyntaxTree.ParseText(file.Value.Source).GetRoot();
133+
var textLines = SourceText.From(file.Value.Source).Lines;
134+
135+
foreach (var mutation in file.Value.Mutants)
151136
{
152-
var syntaxTreeRootNode = CSharpSyntaxTree.ParseText(file.Value.Source).GetRoot();
153-
var textLines = SourceText.From(file.Value.Source).Lines;
154-
155-
foreach (var mutation in file.Value.Mutants)
156-
{
157-
var linePositionSpan = new LinePositionSpan(new LinePosition(mutation.Location.Start.Line - 1, mutation.Location.Start.Column), new LinePosition(mutation.Location.End.Line - 1, mutation.Location.End.Column));
158-
var textSpan = textLines.GetTextSpan(linePositionSpan);
159-
var node = syntaxTreeRootNode.FindNode(textSpan);
160-
var nodeKind = node.Kind();
161-
_blacklistedSyntaxKindsForMutating.ShouldNotContain(nodeKind);
162-
163-
node.AncestorsAndSelf().ShouldContain(pn => _parentSyntaxKindsForMutating.Contains(pn.Kind()));
164-
}
137+
var linePositionSpan = new LinePositionSpan(new LinePosition(mutation.Location.Start.Line - 1, mutation.Location.Start.Column), new LinePosition(mutation.Location.End.Line - 1, mutation.Location.End.Column));
138+
var textSpan = textLines.GetTextSpan(linePositionSpan);
139+
var node = syntaxTreeRootNode.FindNode(textSpan);
140+
var nodeKind = node.Kind();
141+
_blacklistedSyntaxKindsForMutating.ShouldNotContain(nodeKind);
142+
143+
node.AncestorsAndSelf().ShouldContain(pn => _parentSyntaxKindsForMutating.Contains(pn.Kind()));
165144
}
166145
}
146+
}
167147

168-
private void CheckReportMutants(IJsonReport report, int total, int ignored, int survived, int killed, int timeout, int nocoverage)
169-
{
170-
var actualTotal = report.Files.Select(f => f.Value.Mutants.Count()).Sum();
171-
var actualIgnored = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Ignored.ToString())).Sum();
172-
var actualSurvived = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Survived.ToString())).Sum();
173-
var actualKilled = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Killed.ToString())).Sum();
174-
var actualTimeout = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Timeout.ToString())).Sum();
175-
var actualNoCoverage = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.NoCoverage.ToString())).Sum();
176-
177-
report.Files.ShouldSatisfyAllConditions(
178-
() => actualTotal.ShouldBe(total),
179-
() => actualIgnored.ShouldBe(ignored),
180-
() => actualSurvived.ShouldBe(survived),
181-
() => actualKilled.ShouldBe(killed),
182-
() => actualTimeout.ShouldBe(timeout),
183-
() => actualNoCoverage.ShouldBe(nocoverage)
184-
);
185-
186-
CheckMutationKindsValidity(report);
187-
}
148+
private void CheckReportMutants(IJsonReport report, int total, int ignored, int survived, int killed, int timeout, int nocoverage)
149+
{
150+
var actualTotal = report.Files.Select(f => f.Value.Mutants.Count()).Sum();
151+
var actualIgnored = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Ignored.ToString())).Sum();
152+
var actualSurvived = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Survived.ToString())).Sum();
153+
var actualKilled = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Killed.ToString())).Sum();
154+
var actualTimeout = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.Timeout.ToString())).Sum();
155+
var actualNoCoverage = report.Files.Select(f => f.Value.Mutants.Count(m => m.Status == MutantStatus.NoCoverage.ToString())).Sum();
156+
157+
report.Files.ShouldSatisfyAllConditions(
158+
() => actualTotal.ShouldBe(total),
159+
() => actualIgnored.ShouldBe(ignored),
160+
() => actualSurvived.ShouldBe(survived),
161+
() => actualKilled.ShouldBe(killed),
162+
() => actualTimeout.ShouldBe(timeout),
163+
() => actualNoCoverage.ShouldBe(nocoverage)
164+
);
188165

189-
private void CheckReportTestCounts(IJsonReport report, int total)
190-
{
191-
var actualTotal = report.TestFiles.Sum(tf => tf.Value.Tests.Count);
166+
CheckMutationKindsValidity(report);
167+
}
192168

193-
actualTotal.ShouldBe(total);
194-
}
169+
private void CheckReportTestCounts(IJsonReport report, int total)
170+
{
171+
var actualTotal = report.TestFiles.Sum(tf => tf.Value.Tests.Count);
172+
173+
actualTotal.ShouldBe(total);
195174
}
196175
}

src/Directory.Packages.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@
1212
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.11.0" />
1313
<PackageVersion Include="NuGet.Protocol" Version="6.12.1" />
1414
<PackageVersion Include="ResXResourceReader.NetStandard" Version="1.3.0" />
15-
<PackageVersion Include="YamlDotNet" Version="16.2.0" />
15+
<PackageVersion Include="YamlDotNet" Version="16.2.1" />
1616
<PackageVersion Include="Grynwald.MarkdownGenerator" Version="3.0.106" />
17-
<PackageVersion Include="LibGit2Sharp" Version="0.30.0" />
18-
<PackageVersion Include="FSharp.Compiler.Service" Version="42.7.100-preview.22427.1" />
17+
<PackageVersion Include="LibGit2Sharp" Version="0.31.0" />
1918
<PackageVersion Include="DotNet.Glob" Version="3.1.3" />
2019
<PackageVersion Include="Buildalyzer" Version="7.1.0" />
2120
<PackageVersion Include="Microsoft.Web.LibraryManager.Build" Version="2.1.175" />

0 commit comments

Comments
 (0)