Skip to content

Instantly share code, notes, and snippets.

@HowardvanRooijen
Created June 23, 2020 22:20
Show Gist options
  • Save HowardvanRooijen/929950cf41e1cdaa26941d4f2c9da050 to your computer and use it in GitHub Desktop.
Save HowardvanRooijen/929950cf41e1cdaa26941d4f2c9da050 to your computer and use it in GitHub Desktop.
[Binding]
public class NUnit3Hooks
{
[BeforeFeature("workingdirectory_feature")]
public static void ChangeWorkingDirectory()
{
FeatureContext.Current.Add("NUnit3Hooks.OldWorkingDirectory", Directory.GetCurrentDirectory());
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
[AfterFeature("workingdirectory_feature")]
public static void RestoreWorkingDirectory()
{
Directory.SetCurrentDirectory(FeatureContext.Current.Get("NUnit3Hooks.OldWorkingDirectory"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment