From ed04d979003c4f7d1946de23d280e732903a31b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1sp=C3=A1r=20Nagy?= Date: Fri, 8 Nov 2024 16:30:07 +0100 Subject: [PATCH] Fix: NUnit projects fail or provide warning as `TearDown : System.InvalidOperationException : Only static OneTimeSetUp and OneTimeTearDown are allowed for InstancePerTestCase mode.` (#320) --- CHANGELOG.md | 4 +++- .../UnitTestProvider/NUnit3TestGeneratorProvider.cs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index db6e9bcc1..8311eca5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ ## Bug fixes: -*Contributors of this release (in alphabetical order):* +* Fix: NUnit projects fail or provide warning as `TearDown : System.InvalidOperationException : Only static OneTimeSetUp and OneTimeTearDown are allowed for InstancePerTestCase mode.` (#320) + +*Contributors of this release (in alphabetical order):* @gasparnagy # v2.2.0 - 2024-11-07 diff --git a/Reqnroll.Generator/UnitTestProvider/NUnit3TestGeneratorProvider.cs b/Reqnroll.Generator/UnitTestProvider/NUnit3TestGeneratorProvider.cs index 34cfd81e0..1d881bd4c 100644 --- a/Reqnroll.Generator/UnitTestProvider/NUnit3TestGeneratorProvider.cs +++ b/Reqnroll.Generator/UnitTestProvider/NUnit3TestGeneratorProvider.cs @@ -57,7 +57,7 @@ public virtual void SetTestClassInitializeMethod(TestClassGenerationContext gene public virtual void SetTestClassCleanupMethod(TestClassGenerationContext generationContext) { - generationContext.TestClassInitializeMethod.Attributes |= MemberAttributes.Static; + generationContext.TestClassCleanupMethod.Attributes |= MemberAttributes.Static; CodeDomHelper.AddAttribute(generationContext.TestClassCleanupMethod, TESTFIXTURETEARDOWN_ATTR_NUNIT3); }