简体   繁体   中英

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?

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

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 .

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM