Open Sbou opened 6 years ago
@rchande I investigated further into this and realised that we are only reading the "unitTestDebuggingOptions" to create a launch configuration for debugging. We do not have any mechanism to accept the settings for running the test and passing it to omnisharp.
IMO, we should pass these options along with the "RunTest" request and add code in omnisharp that reads these settings and passes them on to the cli process. Thoughts ?
To be clear, "args" is not currently a valid option to "unitTestDebuggingOptions", and, from what I recall, I don't think it ever could be as the debugger is asked to attach to the process.
Would it be better to make a different unit test option rather than adding this onto "unitTestDebuggingOptions"?
Should we allow any args to the unit test runner? Or do we want to make this just for settings files?
Does this belong in a VS Code options file? Or would it make more sense in omnisharp.json?
@gregg-miskelly Cool, thanks for clarifying that. It would probably make sense to have some kind of explicit "testSettings" option that you could set.
OmniSharp.json might be a better location for the setting simply because it's always a file in the repo. We wouldn't want users to accidentally configure this setting in their workspace settings in VS Code (as oppposed to putting a .vscode settings file in their repo). What do you think?
Yes, that was my thinking as well.
Any progress on that issue? We have the same problem. Our projects extensively use custom variable in projects (SolutionDir) which is not present in VS Code. We configured tasks.json to provide it and it works. If running from command line we use "export SolutionDir=" (we use Linux) before running dotnet. But this variable blocks our usage of "Run Test/Debug Test" Code Lens. Providing custom options or/and variables would be very helpful.
My use case is that I'd like to run plain NUnit tests in a Unity project. The Unity vscode integration generates several .csproj files, along with one .sln file. When I click a Run Test link, I get:
MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file.
I'm hoping the fix to this ticket would allow me to solve the above error. Alternately some built-in support for running tests out of the box in Unity projects wouldn't be bad :)
I've started hitting this issue working on the DllImportGenerator project in dotnet/runtimelab.
Environment data
dotnet --info
output: .NET Core SDK (reflecting any global.json): Version: 2.1.302 Commit: 9048955601Runtime Environment: OS Name: ubuntu OS Version: 18.04 OS Platform: Linux RID: ubuntu.18.04-x64 Base Path: /usr/share/dotnet/sdk/2.1.302/
Host (useful for support): Version: 2.1.2 Commit: 811c3ce6c0
.NET Core SDKs installed: 2.1.202 [/usr/share/dotnet/sdk] 2.1.302 [/usr/share/dotnet/sdk]
.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download
VS Code version: 1.25.1 C# Extension version: 1.15.2
Steps to reproduce
Create an MSTest project. Create a runsettings file with parameters. Add this settings to the workspace settings
"csharp.unitTestDebuggingOptions":{ "args":["--settings:myfile.runsettings"] }
Expected behavior
The parameters are loaded to the TestContext.Properties.
Actual behavior
Unable to access this parameters when I debug the test when reading TestContext.Properties.