From e46971a3ccf66a623fa3533956e5f89a25dd2dcb Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Tue, 2 Jun 2026 14:43:29 -0500 Subject: [PATCH] [tests] Replace legacy [TestFixtureSetUp]/[TestFixtureTearDown] with [OneTimeSetUp]/[OneTimeTearDown] The legacy `[TestFixtureSetUp]` and `[TestFixtureTearDown]` attributes were removed in NUnit 3 in favor of `[OneTimeSetUp]` and `[OneTimeTearDown]`. They have been kept around in NUnitLite for back-compat, which is why the on-device Android test path used them under `#if __ANDROID__`. NUnitLite also supports the modern `OneTime*` names, so the conditional is no longer needed. Replacing the conditional with the unconditional modern attribute unblocks dotnet/android#11224, which migrates Mono.Android device tests from NUnitLite to stock NUnit 3.13.3 + MTP via `dotnet test`. Stock NUnit 3.13.3's `netstandard2.0` assembly does not contain the legacy attribute names, so consuming this code there currently requires a small compatibility shim (NUnitCompatibility.cs). After this change that shim can be deleted. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Java.Interop-Tests/Java.Interop/JavaArrayContract.cs | 8 -------- .../Java.Interop/JavaObjectArrayTest.cs | 8 -------- tests/Java.Interop-Tests/Java.Interop/TestTypeTests.cs | 8 -------- 3 files changed, 24 deletions(-) diff --git a/tests/Java.Interop-Tests/Java.Interop/JavaArrayContract.cs b/tests/Java.Interop-Tests/Java.Interop/JavaArrayContract.cs index b3292642c..1279e2842 100644 --- a/tests/Java.Interop-Tests/Java.Interop/JavaArrayContract.cs +++ b/tests/Java.Interop-Tests/Java.Interop/JavaArrayContract.cs @@ -12,21 +12,13 @@ public abstract class JavaArrayContract : ListContract { int lrefStartCount; -#if __ANDROID__ - [TestFixtureSetUp] -#else // __ANDROID__ [OneTimeSetUp] -#endif // __ANDROID__ public void StartArrayTests () { lrefStartCount = JniEnvironment.LocalReferenceCount; } -#if __ANDROID__ - [TestFixtureTearDown] -#else // __ANDROID__ [OneTimeTearDown] -#endif // __ANDROID__ public void EndArrayTests () { int lref = JniEnvironment.LocalReferenceCount; diff --git a/tests/Java.Interop-Tests/Java.Interop/JavaObjectArrayTest.cs b/tests/Java.Interop-Tests/Java.Interop/JavaObjectArrayTest.cs index 896c1c9a6..f28fd7c02 100644 --- a/tests/Java.Interop-Tests/Java.Interop/JavaObjectArrayTest.cs +++ b/tests/Java.Interop-Tests/Java.Interop/JavaObjectArrayTest.cs @@ -158,11 +158,7 @@ public class JavaObjectArray_object_ContractTest : JavaObjectArrayContractTest