The /fixture option goes back to an earlier time, when folks would
completely set up the sequence of tests using it. As new features
have been added to NUnit, they generally didn't get applied to
to test suites (what we now call "legacy suites"). In fact, they didn't
even support TestFixtureSetUp originally, although they now do.
TestFixtureSetup is the answer to your problem. Put your setup
code in a [TestFixtureSetUp] method and the teardown into the
[TestFixtureTearDown] method. Depending on how your code
is written, you may be able to call the methods in your
SetUpFixture, or you may have to cut and paste it.
Charlie
> --
> You received this message because you are subscribed to the Google Groups "NUnit-Discuss" group.
> To post to this group, send email to nunit-...@googlegroups.com.
> To unsubscribe from this group, send email to nunit-discus...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/nunit-discuss?hl=en.
>
>
On Thu, Aug 18, 2011 at 9:57 PM, Ergwun <erg...@gmail.com> wrote:
> Hi Charlie,
>
> What I'm really looking for is a way to provide global setup that is
> called once before executing any tests in any fixtures in an assembly.
> That's how a [SetUpFixture] placed outside any namespace functions a
> the moment, except when the /fixture option is used. I don't need the /
> fixture option when using the console test runner, as I can specify
> fixtures using the /run option, but I am stuck when using the GUI test
> runner.
>
> As I understand it, your recommendation of using [TestFixtureSetup]
> would require the setup being added to each fixture, rather than once
> globally. Please correct me if that is wrong.
That's correct.
> The possible solutions I was hoping might exist would be either:
> a) An equivalent to the console runner's /run=MyFixture option for the
> GUI runner that doesn't stop a global [SetUpFixture] from working; or
> b) An alternative to a global [SetUpFixture] that still works when
> using the /fixture option.
Neither of those is available.
> Since it seems the /fixture option is approaching deprecation (and has
> the negative side effect of negating a global SetUpFixture), it would
> be nice if the /run option for the GUI runner worked the same way as
> the console runner.
Actually, it has been deprecated for a while, it's just that there's no
particular way to tell you that it's deprecated unless we issue a warning
from nunit-console. We may start doing that in 2.6.
For historical reasons, the /run option on the Gui doesn't take any
argument and simply executes all the tests that are loaded. We could
keep /run in it's current meaning and add /test (the new console option
replacing /run) to specify what is to be run.
Before doing that, I'd want to know whether there is much chance that
folks would use it, since it's more intended for batch execution than
for interactive use. The most likely outcome is that we'll find a way
to incorporate legacy suites or their future equivalent in the 3.0 gui.
You would then just click on them and execute.
For now, I'm afraid that the workaround I suggested is all that's
available. You can avoid coding it for every fixture separately by
use of a base class. However, it will still execute multiple times,
so you may want to use a flag to avoid re-running any code
that shouldn't be re-run.
Charlie
Charlie