title: xUnit.net: Global setup + teardown?
body: <p>This question is about the unit testing framework <a href="https://xunit.net/" rel="noreferrer">xUnit.net</a>.</p>
  
  <p>I need to run some code before any test is executed, and also some code after all tests are done. I thought there should be some kind of attribute or marker interface to indicate the global initialization and termination code, but couldn't find them.</p>
  
  <p>Alternatively, if I invoke xUnit programmatically, I can also achieve what I want with the following code:</p>
  
  <pre><code>static void Main()
  {
      try
      {
          MyGlobalSetup();
          RunAllTests();  // What goes into this method?
      }
      finally
      {
          MyGlobalTeardown();
      }
  }
  </code></pre>
  
  <p>Can anyone provide me a hint about how to declaratively or programmatically run some global setup/teardown code?</p>