Class level [Parallelizable(ParallelScope.None)] not overriding Assembly level [assembly: Parallelizable(ParallelScope.Fixtures)]?

332 views
Skip to first unread message

Jeremy Dunn

unread,
Nov 16, 2016, 1:22:27 PM11/16/16
to NUnit-Discuss
I have two test fixtures I am looking to run serially. Since most of my other tests run in parallel I have the assembly attribute set to parallelize. From what I gather in the documentation(https://github.com/nunit/docs/wiki/Parallelizable-Attribute). setting the class level attribute to ParallelScope.None should override the assembly level attribute for any fixtures contained in that class, right? Here's some simplified code:

{AssemblyInfo.cs}:

...
[assembly: Parallelizable(ParallelScope.Fixtures)]

...


{MyTests.cs}:


[Parallelizable(ParallelScope.None)]
public class MyNBTests
{
     
[TestFixtureSource(typeof(MyTestFactory))]
     
public class MyTest1 : BaseTestClass
       
{
           
//Test method
       
}
 

   
[TestFixtureSource(typeof(MyTestFactory))]
   
public class MyTest2 : BaseTestClass
       
{
           
//Test method
       
}
}


If I move the attribute onto each test individually, it works as I expect:

public class MyNBTests
{

   
[Parallelizable(ParallelScope.None)]
   
[TestFixtureSource(typeof(MyTestFactory))]        
   
public class MyTest1 : BaseTestClass
       
{
           
//Test method
       
}

   
[Parallelizable(ParallelScope.None)]
   
[TestFixtureSource(typeof(MyTestFactory))]
   
public class MyTest2 : BaseTestClass
       
{
           
//Test method
       
}
}

Should I not expect a parent class' attribute to override the children [TestFixture] classes?
 

Charlie Poole

unread,
Nov 16, 2016, 1:41:27 PM11/16/16
to NUnit-Discuss

Historically, NUnit has never treated nested classes in any special way. For example, selecting the outer class doesn't cause the nested classes to be run. So what you're seeing is consistent even if surprising. We have talked about treating nested classes as subtests but nothing has been implemented.

Charlie


--
You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nunit-discuss+unsubscribe@googlegroups.com.
To post to this group, send email to nunit-...@googlegroups.com.
Visit this group at https://groups.google.com/group/nunit-discuss.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages