Stryker.NET
  • Introduction
  • Quickstart
  • Quickstart

    Install Stryker using NuGet.

    Global install

    dotnet tool install -g dotnet-stryker
    

    Project install Starting from dotnet core 3.0 dotnet tools can also be installed on a project level. This requires the following steps:

    Create a file called dotnet-tools.json in your project folder. You can checkin to version control to make sure all team members have access to stryker

    dotnet new tool-manifest
    

    Then install stryker without the -g flag while executing the following command in the project folder

    dotnet tool install dotnet-stryker
    

    Update stryker dotnet tool Dotnet global tools do not auto update. To update stryker as a global tool run dotnet tool update


    2 Let's kill some mutants

    Run Stryker.NET to mutation test your project.

     dotnet stryker

    Make sure the command is executed with the test project as current directory.


    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.

    Example config 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?