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

RunSettingsFilePath property isn't honored by VSTest #2265

Closed
ViktorHofer opened this issue Dec 4, 2019 · 2 comments · Fixed by #2272
Closed

RunSettingsFilePath property isn't honored by VSTest #2265

ViktorHofer opened this issue Dec 4, 2019 · 2 comments · Fixed by #2272
Assignees

Comments

@ViktorHofer
Copy link
Member

The property RunSettingsFilePath which points to the local .runsettings file for the test session should be honored by VSTest and not just by Visual Studio. Doc that points to that property: https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2019#visual-studio-2019-version-164-and-later

We need this in the runtime repo (converged repo of coreclr, corefx and core-setup) to configure our test sessions without always needing to type the path to the runsettings file. Our end-goal is that dotnet test is sufficient to run our tests.

cc @ManishJayaswal @singhsarab

@nohwnd nohwnd self-assigned this Dec 9, 2019
@nohwnd
Copy link
Member

nohwnd commented Dec 9, 2019

A simple repro for this is to have a MSTest test project with a single inconclusive test and force the inconclusive state to translate to fail via run settings. This will give a failing test when settings are picked up and a skipped test when they are not.

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace UnitTestProject1
{
    [TestClass]
    public class UnitTest1
    {
        [TestMethod]
        public void TestMethod1()
        {
            Assert.Inconclusive();
        }
    }
}

Add the following example.runsettings in your solution folder

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <MSTest>
    <MapInconclusiveToFailed>True</MapInconclusiveToFailed>
  </MSTest>
</RunSettings>

and configure the project to pick up the settings file by adding this to your csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>

    <IsPackable>false</IsPackable>

+    <RunSettingsFilePath>$(SolutionDir)\example.runsettings</RunSettingsFilePath>
  </PropertyGroup>

Now running it via Test runner will report the test as failed, while running it via dotnet test will report the test as skipped.

image

@vritant24
Copy link
Member

This issue is currently being discussed here #2229

nohwnd added a commit to nohwnd/vstest that referenced this issue Dec 12, 2019
Uses the RunSettingsFilePath from project file when specified and falls
back to the one specified in console, or the default setting if none are
provided.

The path to the settings file can be specified in multiple ways,
for example as a path relative to the project file. This enables
`dotnet test` to be invoked against the project file directly.

```xml
<RunSettingsFilePath>$(ProjectDir)..\example.runsettings</RunSettingsFilePath>
```

Alternatively path can also be specified relatively to solution file, but that will
only work when running dotnet test against the solution. On the other hand the
setting will be the same in all projects.

```xml
<RunSettingsFilePath>$(SolutionDir)\example.runsettings</RunSettingsFilePath>
```

Fixes microsoft#2265
nohwnd added a commit that referenced this issue Dec 16, 2019
Uses the RunSettingsFilePath from project file when specified and falls
back to the one specified in console, or the default setting if none are
provided.

The path to the settings file can be specified in multiple ways,
for example as a path relative to the project file. This enables
`dotnet test` to be invoked against the project file directly.

```xml
<RunSettingsFilePath>$(ProjectDir)..\example.runsettings</RunSettingsFilePath>
```

Alternatively path can also be specified relatively to solution file, but that will
only work when running dotnet test against the solution. On the other hand the
setting will be the same in all projects.

```xml
<RunSettingsFilePath>$(SolutionDir)\example.runsettings</RunSettingsFilePath>
```

Fixes #2265
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants