Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nunit parallel attributes in .net core

I have very simple question but can't find in Google any information about it.

I use NUnit3 and NunitAdapter to run my tests through Visual Studio or dotnet test on build agents. I need to add attributes [assembly: Parallelizable()] and [assembly: LevelOfParallelism()].

But netCore project haven't assemblyInfo.cs and I don't know where to add this attributes. Where it should be placed?

P.S: I had never worked with netCore before, we migrated to it few days ago.

like image 825
Ilya Shmin Avatar asked Jun 08 '26 22:06

Ilya Shmin


2 Answers

You can place that attribute in any file you like, it doesn't have to be AssemblyInfo.cs. Having said that, I like to keep these things separate or they become easy to miss so I would advise you keep them in a distinct file, and probably call it AssemblyInfo.cs.

like image 181
DavidG Avatar answered Jun 10 '26 14:06

DavidG


As explained into NUnit documentation you can specify Parallelizable Attribute at test level

  • ParallelScope.Self = the test itself may be run in parallel with other tests
  • ParallelScope.Children = child tests may be run in parallel with one another
  • ParallelScope.Fixtures = fixtures may be run in parallel with one another

For example

[TestFixture]
[Parallelizable(ParallelScope.All)]

Or alternatively, you can add a file and call it AssemblyInfo.cs

like image 27
Luigi Saggese Avatar answered Jun 10 '26 14:06

Luigi Saggese



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!