mardi 22 mars 2016

How to create a Global Initialization in NUnit 3.2?

I've trying to design a test suit to run a global initialization before all my tests. We can consider that exists tests in differents classes and namespaces. In NUnit documentation I only found a attribute named OneTimeSetUp, but it works only for tests in the same namespace.

So, I designed using inherting. all my tests classes inhert a base test class where his constructor does the global inicialization (whith the help of a static variable to check if it was or not initialized), and the same to a global tear down in the destructor.

Using it I could create my scenario. But when the test suit runs, the base test class creates new objects because there are tests in differents classes and namespaces. It cause a overloard in the system and the next tests runs slow: the first test runs in 50 seconds, while another (that do the same thing but in a different namespace) runs in 120 seconds.

There is a better way to create a global inicialization and a global teardown without impact the test performance

Aucun commentaire:

Enregistrer un commentaire