I am trying to develop a test suit to run global initialization before all my trials. We can assume that there are tests in different classes and namespaces. In the NUnit documentation, I found only the OneTimeSetUp attribute, but it only works for tests in the same namespace.
So, I developed using inheritance. all of my test classes inherit the base test class, where its constructor performs global initialization (using a static variable to check if it was initialized or not initialized), and the same thing with a global break in the destructor.
Using it, I could create my own script. But when the test suit works, the base test class creates new objects because there are tests in different classes and namespaces. This causes an excess number in the system, and the following tests run slowly: the first test runs after 50 seconds, and the other (which does the same, but in a different namespace) runs after 120 seconds.
There is a better way to create global initialization and global shutdown without affecting test performance
source share