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?
Hello,
Thank you for sharing the code samples.
Currently, the CodeRush Test Runner has limited support for .runsettings files. It supports the .runsettings file specified in Visual Studio in some usage scenarios but doesn't consider the RunSettingsFilePath property of a project. We will consider the possibility of improving support for .runsettings files in future updates. Please specify the following points so that I can provide you with more detailed information:
I am looking forward to your response.
Hi Alexander,
Thanks for the reply. I have attached a sample of what I am trying to accomplish, but to answer your questions:
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.
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.