Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Working directory fix #346

Merged
merged 4 commits into from
Jan 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public virtual TestProcessStartInfo GetTestHostProcessStartInfo(
// G:\tmp\netcore-test\bin\Debug\netcoreapp1.0\netcore-test.dll
startInfo.Arguments = args;
startInfo.EnvironmentVariables = environmentVariables ?? new Dictionary<string, string>();
startInfo.WorkingDirectory = Directory.GetCurrentDirectory();
startInfo.WorkingDirectory = sourceDirectory;

return startInfo;
}
Expand Down
15 changes: 15 additions & 0 deletions test/Microsoft.TestPlatform.AcceptanceTests/ExecutionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,20 @@ public void RunMultipleTestAssembliesInParallel(string runnerFramework, string t
$"Number of {testhostProcessName} process created, expected: {expectedNumOfProcessCreated} actual: {numOfProcessCreatedTask.Result}");
this.ValidateSummaryStatus(2, 2, 2);
}

[CustomDataTestMethod]
[NET46TargetFramework]
[NETCORETargetFramework]
public void WorkingDirectoryIsSourceDirectory(string runnerFramework, string targetFramework, string targetRuntime)
{
AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerFramework, targetFramework, targetRuntime);

var assemblyPaths =
this.BuildMultipleAssemblyPath("SimpleTestProject3.dll").Trim('\"');
var arguments = PrepareArguments(assemblyPaths, this.GetTestAdapterPath(), string.Empty, this.FrameworkArgValue);
arguments = string.Concat(arguments, " /tests:WorkingDirectoryTest");
this.InvokeVsTest(arguments);
this.ValidateSummaryStatus(1, 0, 0);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ public void GetTestHostProcessStartInfoShouldThrowExceptionWhenDotnetIsNotInstal
}

[TestMethod]
public void GetTestHostProcessStartInfoShouldIncludeCurrentDirectoryAsWorkingDirectory()
public void GetTestHostProcessStartInfoShouldIncludeSourceDirectoryAsWorkingDirectory()
{
// Absolute path to the source directory
var sourcePath = Path.Combine($"{Path.DirectorySeparatorChar}tmp", "test.dll");
this.mockFileHelper.Setup(ph => ph.Exists(@"\tmp\testhost.dll")).Returns(true);
var startInfo = this.dotnetHostManager.GetTestHostProcessStartInfo(new[] { sourcePath }, null, this.defaultConnectionInfo);

Assert.AreEqual(Directory.GetCurrentDirectory(), startInfo.WorkingDirectory);
Assert.AreEqual($"{Path.DirectorySeparatorChar}tmp", startInfo.WorkingDirectory);
}

[TestMethod]
Expand Down
7 changes: 0 additions & 7 deletions test/TestAssets/SimpleTestProject3/SimpleTestProject3.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp1.0;net46;netcoreapp1.1</TargetFrameworks>
<AssemblyName>SimpleTestProject3</AssemblyName>
<PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.0' Or '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);dnxcore50;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MSTest.TestFramework">
Expand All @@ -24,12 +23,6 @@
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'netcoreapp1.0' Or '$(TargetFramework)' == 'netcoreapp1.1' ">
<DebugType>portable</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(TargetFramework)' == 'net46'">
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DefineConstants>$(DefineConstants);RELEASE</DefineConstants>
</PropertyGroup>
Expand Down
8 changes: 7 additions & 1 deletion test/TestAssets/SimpleTestProject3/UnitTest1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
namespace SampleUnitTestProject3
{
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.IO;
using System.Reflection;

[TestClass]
public class UnitTest1
{

[TestMethod]
public void WorkingDirectoryTest()
{
Assert.AreEqual(Path.GetDirectoryName(typeof(UnitTest1).GetTypeInfo().Assembly.Location), Directory.GetCurrentDirectory());
}
}
}