Running individual NUnit tests programmatically

前端 未结 2 1791
渐次进展
渐次进展 2021-02-09 23:10

I need to run individual C# NUnit tests programmatically. I found another post that was very helpful in showing me how to run an entire set of tests programmatically, but I need

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-09 23:35

    I had to pass a filter as well, just executing

    TestResult testResult = remoteTestRunner.Run(new NullListener(), null , false, LoggingThreshold.Error);
    

    ended in a NullReferenceException. I quickly created an empty filter

    class EmptyFilter : TestFilter
    {
    
        public override bool Match(ITest test)
        {
            return true;
        }
    }
    

    and passed it to the remoteTestRunner.

    TestResult testResult = remoteTestRunner.Run(new NullListener(), new EmptyFilter() , false, LoggingThreshold.Error);
    

    That worked. What one could invest a little is to search whether NUnit already has a similar Filter that could be reused rather than creating a custom one.

提交回复
热议问题