-
Notifications
You must be signed in to change notification settings - Fork 727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is there a global (process wide) setup or teardown available? #4106
Comments
You can create a Setup fixture class. |
Thanks for the reply. As I wrote, I already tried out to use |
Thanks @Netzeband |
Hello, does anyone has an idea? |
I guess you'll have to code it yourself. Depending on how you execute your tests then the different assemblies can be executed in parallel in different processes, so you'll need some some global lock (the OS, the filesystem, or a database) to ensure that only the first setup running - in a given assembly - will setup the external library. If you also need to tear it down, then you'll need to keep track of the assemblies started, so only the last stopping assembly will tear it down. I have the feeling that this problem will be hard to solve in the framework (alone). |
The initialization is quite easy. Since my tests are not running in different processes, I just use a global flag to indicate, if the library was already initialized and prevent a double initialization. The real problem is the tear down, which is necessary. At the moment, I just skip it, which means the library is throwing a lot of error messages when the process exits. In the beginning, I was thinking, I could use the finanlizer of a static singleton instance to shutdown the library. However, I learned, that in C# finalizers of static instances are not called when the process exits. They are simply ignored. So it can only be handled on application level, which is for unit tests the framework. When I look at the nunit.engine documentation, I think this can get very hard. There is not really an single entry and exit point for the test-runner. Only the Edit: Maybe an nunit.extension could be the solution? There is the |
Hello
I have a usecase, where an external library must be setup exactly once for the whole process and in the end it must be teardown just a single time. Therefore, I'm looking for a process wide setup/teardown mechanism. However, I just found the
OneTimeSetUp
andOneTimeTeatdown
, which is done for every Assembly. This does not work in my case, because the library cannot be setup again after it has been shutdown.Is there any solution for that available?
The text was updated successfully, but these errors were encountered: