@@ -10,6 +10,7 @@ var configuration = Argument<string>("configuration", "Release");
1010//////////////////////////////////////////////////////////////////////
1111
1212#Tool "xunit.runner.console&version=2.4.2"
13+ #Tool "dotnet-stryker&version=3.6.1"
1314
1415//////////////////////////////////////////////////////////////////////
1516// EXTERNAL NUGET LIBRARIES
@@ -46,6 +47,10 @@ string nugetVersion;
4647string assemblyVersion;
4748string assemblySemver;
4849
50+ // Stryker / Mutation Testing
51+ var strykerConfig = File( "./eng/stryker-config.json" ) ;
52+ var strykerOutput = Directory( "StrykerOutput" ) ;
53+
4954///////////////////////////////////////////////////////////////////////////////
5055// INNER CLASSES
5156///////////////////////////////////////////////////////////////////////////////
@@ -84,7 +89,8 @@ Task("__Clean")
8489 {
8590 testResultsDir ,
8691 nupkgDestDir ,
87- artifactsDir
92+ artifactsDir ,
93+ strykerOutput
8894 } ;
8995
9096 CleanDirectories ( cleanDirectories ) ;
@@ -206,6 +212,27 @@ Task("__RunTests")
206212 }
207213} ) ;
208214
215+ Task( "__RunMutationTests" )
216+ . Does ( ( ) =>
217+ {
218+ TestProject ( File ( "./src/Polly/Polly.csproj" ) , File ( "./src/Polly.Specs/Polly.Specs.csproj" ) , "Polly" ) ;
219+ TestProject ( File ( "./src/Polly.Core/Polly.Core.csproj" ) , File ( "./src/Polly.Core.Tests/Polly.Core.Tests.csproj" ) , "Polly.Core" ) ;
220+
221+ void TestProject ( FilePath proj , FilePath testProj , string project )
222+ {
223+ var strykerPath = Context . Tools . Resolve ( "Stryker.CLI.dll" ) ;
224+ var mutationScore = XmlPeek ( proj , "/Project/PropertyGroup/MutationScore/text()" , new XmlPeekSettings { SuppressWarning = true } ) ;
225+ var score = int . Parse ( mutationScore ) ;
226+
227+ Information ( $ "Running mutation tests for '{ proj } '. Test Project: '{ testProj } '") ;
228+ var result = StartProcess ( "dotnet" , $ "{ strykerPath } --project { project } --test-project { testProj } --break-at { score } --config-file { strykerConfig } --output { strykerOutput } /{ project } ") ;
229+ if ( result != 0 )
230+ {
231+ throw new InvalidOperationException ( $ "The mutation testing of '{ project } ' project failed.") ;
232+ }
233+ }
234+ } ) ;
235+
209236Task( "__CreateSignedNuGetPackages" )
210237 . Does ( ( ) =>
211238{
@@ -240,6 +267,7 @@ Task("Build")
240267 . IsDependentOn ( "__UpdateAssemblyVersionInformation" )
241268 . IsDependentOn ( "__BuildSolutions" )
242269 . IsDependentOn ( "__RunTests" )
270+ . IsDependentOn ( "__RunMutationTests" )
243271 . IsDependentOn ( "__CreateSignedNuGetPackages" ) ;
244272
245273///////////////////////////////////////////////////////////////////////////////
0 commit comments