Ilya Shmin
Ilya Shmin

Reputation: 156

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.

Upvotes: 3

Views: 3789

Answers (2)

Luigi Saggese
Luigi Saggese

Reputation: 5379

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

Upvotes: 3

DavidG
DavidG

Reputation: 119156

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.

Upvotes: 5

Related Questions