diff --git a/test/dotnet.Tests/CommandTests/Run/RunParserTests.cs b/test/dotnet.Tests/CommandTests/Run/RunParserTests.cs index 34e8c710645d..73ffc234de7d 100644 --- a/test/dotnet.Tests/CommandTests/Run/RunParserTests.cs +++ b/test/dotnet.Tests/CommandTests/Run/RunParserTests.cs @@ -5,14 +5,23 @@ namespace Microsoft.DotNet.Tests.ParserTests { - public class RunParserTests + public class RunParserTests : IDisposable { + private readonly ITestOutputHelper output; + private readonly string _previousWorkingDirectory; + public RunParserTests(ITestOutputHelper output) { this.output = output; + + // Reset current working directory after tests run to avoid breaking other tests + _previousWorkingDirectory = Directory.GetCurrentDirectory(); } - private readonly ITestOutputHelper output; + public void Dispose() + { + Directory.SetCurrentDirectory(_previousWorkingDirectory); + } [Fact] public void RunParserCanGetArgumentFromDoubleDash() @@ -21,9 +30,8 @@ public void RunParserCanGetArgumentFromDoubleDash() var testAsset = tam.CopyTestAsset("HelloWorld").WithSource(); var newWorkingDir = testAsset.Path; - Directory.SetCurrentDirectory(newWorkingDir); var projectPath = Path.Combine(newWorkingDir, "HelloWorld.csproj"); - + var runCommand = RunCommand.FromArgs(new[] { "--project", projectPath, "--", "foo" }); runCommand.ApplicationArgs.Single().Should().Be("foo"); }