2

I have this setup:

[assembly: CollectionBehavior(CollectionBehavior.CollectionPerAssembly, DisableTestParallelization = true)]

I want to use ICollectionFixture<T> to share an instance to the whole assembly.

It seems that I have to declare a [CollectionDefinition] class to use ICollectionFixture but how can I do it if I use the CollectionPerAssembly approach?

[CollectionDefinition("???")]
class Definition : ICollectionFixture<MySingleton>
{

}
Vlad
  • 3,001
  • 1
  • 22
  • 52

1 Answers1

1

While the naming suggests there is an overlap, this is not the case.

You need to either:

a) have a CollectionDefinition, with every Test Class marked as part of that Collection, and be passed a ref to it via the ctor b) create and access a singleton out of band and/or do prep with a C# 9 module initializer

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249