Build/Test Issues

Xunit tests won't runwhen you have them in a nested class

Started by chrissie1 on 6,357 views

For an example go to the test branch of scriptcs on github. https://github.com/scriptcs/scriptcs/tree/dev/src

They do this.

public class FileProcessorTests
    {
        public class ProcessFileMethod
        {
            private List<string> _file1 = new List<string>
                {


NCrunch does not find any tests. But when I remove the outer class (FileProcessorTests) the tests start to run.

Is there any setting I am missing to resolve this?
Hi, thanks for posting!

This issue is caused by a limitation in the Gallio adapter NCrunch is using to discover Xunit tests. Basically, the adapter doesn't search nested Xunit classes for tests when using Static Analysis. A workaround is to set the 'Framework utilisation type for Gallio/Xunit' solution-level configuration option to 'DynamicAnalysis'.

I'm currently looking for ways to properly solve this problem. It only affects Xunit (not the other frameworks supported by NCrunch).

Cheers,

Remco
For anyone interested, a fix for this problem has been introduced with the newly released version of NCrunch (v1.45), so it's now possible for NCrunch to discover nested Xunit tests using static analysis.

Post a reply

Log in to reply.