Bug Report T1080426
Visible to All Users

Unit Testing - .runsettings file is not taken into account when running .Net Core tests

created 3 years ago

Hello,

I have created a .runsettings file as described in the MS docs: https://docs.microsoft.com/en-us/visualstudio/test/configure-unit-tests-by-using-a-dot-runsettings-file?view=vs-2022

I have then added the following to my test project file:

C#
<PropertyGroup> <RunSettingsFilePath>$(MSBuildProjectDirectory)\test.runsettings</RunSettingsFilePath> </PropertyGroup>

The file looks like this:

C#
<?xml version="1.0" encoding="utf-8"?> <RunSettings> <TestRunParameters> <Parameter name="param1" value="value1" /> </TestRunParameters> </RunSettings>

If I run my unit test using the Visual Studio built in "Test Explorer" then I can access the value param1 like this:

C#
var param1 = TestContext.Parameters.Get("param1")

However, if I run the test under the CodeRush Test Runner then the TestContext.Paramters is empty and I cannot get the value for param1.

Why is this? Does CodeRush not support the runsettings file?

Show previous comments (1)

    Hi Alexander,

    Thanks for the reply. I have attached a sample of what I am trying to accomplish, but to answer your questions:

    1. Yes I am using NUnit
    2. .NET 5
      I cannot get this to work even when trying to set the .runsettings manually via VS: Test --> Configure Run Settings --> Selection Solution Wide runsettings File, but the preference is definitely to be able to define it in the project.
    DevExpress Support Team 3 years ago

      Thank you for sharing your project.

      You are correct that the current CodeRush version doesn't consider the .runsettings file for running .Net Core tests. We have already added support for the .runsettings file that is specified in Visual Studio. We agree that it's important to consider the .runsettings file that is specified in a project. We are working on its implementation and will notify you of our progress.

        Thanks Alexander.

        Answers approved by DevExpress Support

        created 3 years ago

        We have addressed the issue described in this ticket and will include a fix in our next maintenance update. Should you need to apply our fix prior to official release, you can request a hotfix here.

        Important Notes:

        • Hotfixes may be unavailable for Early Access/Beta builds or updates set for release within a week.
        • .NET only: in the NuGet Package Manager, use your personal NuGet feed and check the "Include prerelease" option to view the hotfix package in the "Updates" tab.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.