title: How to filter NUnit tests by category using "dotnet test"
body: <p>I have a project that has a</p>
  
  <pre><code>[TestFixture, Category("Oracle")]
  </code></pre>
  
  <p>and a</p>
  
  <pre><code>[TestFixture, Category("OracleOdbc")]
  </code></pre>
  
  <p>with a couple of tests which I would like to execute <em>separately</em> using <code>dotnet test</code>.</p>
  
  <p>Here's what I tried after some Googling:</p>
  
  <ol>
  <li><code>dotnet test MyProject.csproj --where "cat==Oracle"</code> but this switch does not exists anymore.</li>
  <li><code>dotnet test MyProject.csproj --filter Category="Oracle"</code> yields 0 applicable tests: <code>No test is available in ...</code>.</li>
  </ol>
  
  <p>Then, I've stumbled over <a href="https://docs.microsoft.com/en-us/dotnet/core/testing/selective-unit-tests" rel="noreferrer">this article</a> and although it describes MSTest (and NUnit has the <code>CategoryAttribute</code> and not a <code>TestCategoryAttribute</code>), I've tried</p>
  
  <ol start="3">
  <li><code>dotnet test MyProject.csproj --filter TestCategory="Oracle"</code></li>
  </ol>
  
  <p>Bingo. This time all "Oracle" tests were executed. But now comes the confusing part. If I run <code>dotnet test MyProject.csproj --filter TestCategory="OracleOdbc"</code>, <strong>all</strong> tests are being executed, including "Oracle" <em>and</em> "OracleOdbc". This makes me wonder if <code>TestCategroy</code> is the proper way to go for NUnit or if this is a bug.</p>
  
  <p>I'm using .NET Command Line Tools (2.1.2) and the project references are:</p>
  
  <pre><code>&lt;PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" /&gt;
  &lt;PackageReference Include="NUnit" Version="3.8.1" /&gt;
  &lt;PackageReference Include="NUnit3TestAdapter" Version="3.9.0" /&gt;
  &lt;PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.7" /&gt;
  </code></pre>
  
  <p>BTW, I don't know if it matters but my test project is multi-targeting <code>netcoreapp2.0</code> and <code>net462</code>.</p>