-
Notifications
You must be signed in to change notification settings - Fork 724
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
SetUpFixture not being run if there are no tests #3420
Comments
Hi, @akorczynskikcura !
|
There is no SetUp or TearDown in NUnit, which operates across assemblies. That's because the NUnit framework is invoked separately for each assembly. Such a global SetUp has been requested before, but it would have to operate outside of the framework itself, most likely within the TestEngine. Your workaround in this case is to simply run the code, which performs your global SetUp separately. There's no need for it to be an NUnit test. Note that any SetUp you perform can only usefully impact the overall environment. For example, you could set up a database or create some file. You would not be able to directly change any properties used within the actual tests. Note that any environmental setup you perform has to be accessible to the tests. In order to run multiple test assemblies in parallel, any resources need to be shareable. |
@lobster2012-user you would need to have a new library without any tests, just |
@CharliePoole true, not having a global setup, I can do it in a variety of ways, like create a separate executable or write a regular test, not setup. |
@akorczynskikcura That is the same question raised in #1713 WRT SetUpFixtures. The issue remains open and the question unanswered. My own opinion is that they should not be executed unless tests under them are to be executed, but it's not my decision to make. The comment you cite in #1713, relates to a prior decision about a selected TestFixture containing no tests, which is a different matter. SetUpFixtures of course never contain tests. IMO, both issues should be resolved by updating the docs to describe the current behavior. |
We have a test assembly with just SetUpFixture and no tests. The reason being is that we have multiple test assemblies and want to run setup code before any test executes, so we just run nunit on this special assembly first.
As a workaround I have to add fake test fixture class and fake test.
With this issue #1713 I have read that the agreement was that setups and teardowns are still run even if there are no tests. Is this still true?
Documentation however does not mention anything about it https://github.com/nunit/docs/wiki/SetUpFixture-Attribute.
There is also another issue with SetUpFixture #3356, but it is for newer version and it has a test inside.
I have tested Nunit-console 3.9.0 and 3.10.0. They all succeed, meaning zero tests were found, but SetUpFixture was not executed.
If I tried Nunit 3.12 and Nunitlite-runner it fails not finding test fixtures
Please advise whether this is a bug, what is the expected behavior and what are your recommendations for this scenario. Thank you!
The text was updated successfully, but these errors were encountered: