0
votes

Is it possible to construct a Visual Studio Test Explorer search expression that will actually filter NUnit tests based on the name AND value of a Property attribute? For example, something like Trait:TestSize=Large. I can't seem to figure out how to get this to work and after hours of searching it's unclear if I should be looking for documentation from Visual Studio, NUnit, or the NUnit Test Adapter.

[TestFixture]
public class SampleTestFixture {
  [Test]
  [Property("TestSize", "Large")]
  public void Test1() { ... }
}

More details:

  • Currently using VS 2015, but I want this to work in VS 2017 and 2019
  • Using NUnit 3.12
  • Using NUnit3TestAdapter 3.8
1

1 Answers

0
votes

Im not sure Im understood corectly, but If you want filtering tests for run what you want based on TestCaseName you should use TestEngineAPI. For more info - https://github.com/nunit/docs/wiki/Test-Engine-API

ITestEngine engine = TestEngineActivator.CreateInstance();

TestPackage package = new TestPackage("my.test.assembly.dll");

ITestRunner runner = engine.GetRunner(package);

// Run all the tests in the assembly
XmlNode testResult = runner.Run(this, TestFilter.Empty);

where TestFilter.Empty can be something like this: new TestFilter($"<filter><or><name>Test1</name></or></filter>");