docs icon indicating copy to clipboard operation
docs copied to clipboard

Documentation needed about how to write a "where" statement for test cases resulting from TestCase attribute or TestFixture parameters

Open endrih opened this issue 8 years ago • 1 comments

Please, can you write a couple of more examples in the documentation about the Test Selection Language about how to select tests resulting from TestCase attribute or TestFixture various constructing values etc. For example I have a test that I want to select Test.ClipboardTests("no").TestBug345. I see this full name by doing the following on the assembly:

using (ITestEngine engine = TestEngineActivator.CreateInstance(true))
{
     engine.WorkDirectory = Environment.CurrentDirectory;
     engine.InternalTraceLevel = InternalTraceLevel.Verbose;

     TestPackage package = MakeTestPackage(assemblyName);
     ITestRunner runner = engine.GetRunner(package);
     return runner.Explore(TestFilter.Empty);
} 

The ClipboardTests test fixture has these attributes:

[TestFixture("en-US")]
[TestFixture("no")]
public  class ClipboardTests{
.
.
.
}

I have been trying to single out that test when running the command line by using: --where="test=~/.*Test.ClipboardTests(\"no\").TestBug345.*/" However, that does not work. Of course, if I do --where="test=~/.*Test.ClipboardTests.*/", then I get all the tests in that fixture.

endrih avatar Nov 04 '16 14:11 endrih

We can review the page to see what might be made more clear. In general, I tried to avoid teaching use of regular expressions, which is a pretty large subject, and outside the scope of of NUnit. But perhaps a few examples would help.

In this case, you have included the chars ( and ) which have a special meaning in a regex and must be escaped. Additionally, you used the special character . without escaping it, although that didn't cause the problem. Give it a try with this form:

--where "test=~/Test\.ClipboardTests\(\"no\"\).TestBug345/"

Note that the escaping of " is for the purpose of the command-line, while the other escapes are for the regular expression processing.

CharliePoole avatar Nov 04 '16 17:11 CharliePoole