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

dotnet test in RC4 has the working directory set to the output directory #435

Closed
pranavkm opened this issue Feb 3, 2017 · 6 comments
Closed
Assignees

Comments

@pranavkm
Copy link

pranavkm commented Feb 3, 2017

Description

Not entirely sure if this belongs here, but I specifically see the issue as part of test runs and not while running (dotnet run) the application.
As part of upgrading AspNetCore's repositories to use the RC4 CLI, I noticed that the current directory during test runs is set to the output directory (AppRoot\bin\Debug\netcoreapp1.1) as opposed to the directory from which the test command is called.

Steps to reproduce

What steps can reproduce the defect?

  1. Create a test project
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-*" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-*" />
    <PackageReference Include="xunit" Version="2.2.0-*" />
  </ItemGroup>
</Project>
using System;
using System.IO;
using Xunit;

namespace ConsoleApp
{
    public class Test
    {
        [Fact]
        public void TestMethod()
        {
            Assert.False(true, "Expected path " + Directory.GetCurrentDirectory());
        }
    }
}
  1. Run the test using the RC3 CLI (dotnet test). The test failure should print out the working directory path which would be the project directory.
  2. Run the test using an RC4 CLI. The working directory in the test is $projectDirectory\bin\Debug\netcoreapp1.0.
  3. I don't see the same issue if I simply print Directory.GetCurrentDirectory() as part of dotnet run using the two CLI.

Please share the setup, commandline for vstest.console, sample project, target

RC3 CLI: 1.0.0-rc3-004530
RC4 CLI: 1.0.0-rc4-004756

@pranavkm
Copy link
Author

pranavkm commented Feb 3, 2017

cc @natemcmaster

@natemcmaster
Copy link
Contributor

Should be the directory containing the csproj, if I understood correctly the intent of #346.

@pranavkm
Copy link
Author

pranavkm commented Feb 3, 2017

@natemcmaster #346 makes it seem like this was intentionally changed to point to the output directory.

@NTaylorMullen
Copy link

With how it is today (path not being next to csproj) if you want to work around #196 you must treat the xunit.runner.json as content so it makes its way to the output directory. If it's changed to be at the csproj level you do not need that extra workaround.

@natemcmaster
Copy link
Contributor

@pranavkm good point. The PR description says "source directory" which at first I though was the project dir, but the code changes ensure working directory is the test assembly location.

@NTaylorMullen good to know. Requiring the build to copy xunit.runner.json to output is consistent with how it worked in project.json

@smadala
Copy link
Contributor

smadala commented May 29, 2017

Closing this as behavior change was intentional.

@smadala smadala closed this as completed May 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants