Search code examples
cakebuild

Cake How to Run Specific Test Category


I was wondering if it was possible to run a specific test category? I want to be able to do this equivalently in Cake:

dotnet test --filter TestCategory="foo"

Unsure of how to go about it in Cake, I did notice DotNetCoreTestSettings but not sure how to set the category.


Solution

  • As long as Filter is a property of DotNetCoreTestSettings class, I would expect the following to cover your requirements (similar to the sample found here):

     var settings = new DotNetCoreTestSettings
     {
         Configuration = "Release",
         Filter = "TestCategory=\"foo\""
     };
    
     DotNetCoreTest("./test/Project.Tests/", settings);