I cant see any difference in behaviour for class that has TestFixture
attribute and not. All TearDown
and SetUp
are working in the same way. Is there any reason except semantics for this attribute usage?

- 15,046
- 12
- 60
- 89
-
1Interesting question. NUnit seems to recognise fixtures that don't have the attribute and run them correctly. – Jackson Pope Dec 06 '11 at 14:03
2 Answers
Is purely a convenience, beginning with NUnit 2.5, if a class satisfies the conditions to be a test fixture and specifies at least a method marked with Test
, TestCase
or TestCaseSource
than that class is treated as a test fixture.
The TestFixture
attribute is required however for parameterized or generic test fixture because in that case you also specify additional information through the attribute (parameters/concrete types).
More information about the specific requirements is available at TextFixtureAttribute (NUnit 3 Documentation) and TestFixtureAttribute (NUnit 2.0 / 2.5)

- 157
- 8

- 56,552
- 12
- 145
- 147
If you use [TestFixture]
you have to put up with that voice in the back of your head saying "Hmm, this is a test class, not really a test fixture" and wonder how they got this annotation wrong.
-
9Plus one for making me laugh after a long day of working on [TestFixture] tests. – Piotr Kula Aug 23 '16 at 14:46