From 109f1a860b44ee9bbda2be310639348e80b153d0 Mon Sep 17 00:00:00 2001 From: OsirisTerje Date: Fri, 1 Sep 2023 19:25:54 +0000 Subject: [PATCH] Merge pull request #786 from ramonsmits/OneTimeSetup-run-only-once-guidance Use `SetUpFixture` or static contructor to have code only run once 3bd0d9dcf96199f5736fc8702765a97345bdfea8 --- .../attributes/onetimesetup.html | 2 + index.json | 2 +- sitemap.xml | 700 +++++++++--------- 3 files changed, 353 insertions(+), 351 deletions(-) diff --git a/articles/nunit/writing-tests/attributes/onetimesetup.html b/articles/nunit/writing-tests/attributes/onetimesetup.html index 59e45982c..6b0b0f0ed 100644 --- a/articles/nunit/writing-tests/attributes/onetimesetup.html +++ b/articles/nunit/writing-tests/attributes/onetimesetup.html @@ -137,6 +137,8 @@

Notes

  • When using FixtureLifeCycle with LifeCycle.InstancePerTestCase, the OneTimeSetUp method must be static and is only called once. This is required so that the setup method does not access instance fields or properties that are reset for every test.

  • +
  • When set on a base class the method is invoked for each fixture that inherits from this base class and its invoked for the base class too if its not abstract. Use SetUpFixture if this only needs to be run once or put the code in a static constructor.

    +
  • See Also