For C#
  • Introduction
  • Quickstart
  • Quickstart

    Install Stryker using NuGet.

    1 Install

    To install Stryker.NET on your test project add the following lines to the root of your .csproj file. on your test project.

    <ItemGroup>
        <DotNetCliToolReference Include="StrykerMutator.DotNetCoreCli" Version="*" />
        <PackageReference Include="StrykerMutator.DotNetCoreCli" Version="*" />
    </ItemGroup>
    

    After adding the references, install the packages by executing dotnet restore inside the project folder.

    dotnet restore 
    

    2 Let's kill some mutants

    Run Stryker.NET to mutation test your project

     dotnet stryker

    3 Configure

    Stryker will always look for a stryker-config.json file in the root of the test project. When found it will use the parameters in the file.

    {
        "stryker-config":
        {      
            "reporters":[
                "ConsoleProgressBar",
                "ConsoleReport"
            ],  
            "log-level":"info",
            "timeout-ms":10000,
            "log-file":true,
            "project-file":"ExampleProject.csproj",
            "max-concurrent-test-runners":4,
            "threshold-high":80,
            "threshold-low":70,
            "threshold-break":60,
            "files-to-exclude": [
                "./ExampleClass.cs",
                "./ExampleDirectory/",
                "./ExampleDirectory/ExampleClass2.cs",
                "C:\\ExampleRepo\\ExampleDirectory\\ExampleClass.cs"
            ],
            "excluded-mutations": [
                "string",
                "Logical operators"
            ]
        }
    }
    

    All the arguments in the configuration are optional.

    Note

    In some cases Stryker cannot run without the project-file argument. Specify the name of the referenced project that should be mutated here. Stryker can only mutate one project in a single run. When it finds more references it will use the name in project-file to find the one project to mutate.

    For more information on what these options mean, take a look at the Stryker.NET readme

    Console

    All arguments can also be passed through the console.

    dotnet stryker --log-level debug
    

    Arguments both assigned in the config file and the console will use the value assigned in the console.

    Need help?