Filter on Category for NUnit MSBuild tasks?

2019-07-07 22:23发布

问题:

I'm setting up a MSBuild project to run some NUnit test, using the MSBuild Community Tasks Project.

With these settings I'll be able to run the NUnit tests:

<Target Name="Test" DependsOnTargets="Build">
    <CreateItem Include="$(ProjectTestDir)\$(ClassLibraryOutputDirectory)\*.Tests.dll">
        <Output TaskParameter="Include" ItemName="TestAssembly" />
    </CreateItem>
    <NUnit Assemblies="@(TestAssembly)" />
</Target>

... but how can i run only certain tests - say the ones with a specific Category? We've added different categories to our tests - some to run all the time, some to only run at a nightly build etc.

I don't see any settings allowing me to filter on this, or did I miss something? Surely some of you have had this same problem and solved it somehow? It doesn't have to be using this msbuild community tasks project.

回答1:

Looking in the CHM, there's an IncludeCategory property... sounds like what you're looking for? (The CHM file is installed in C:\Program Files (x86)\MSBuild\MSBuildCommunityTasks)