-
Notifications
You must be signed in to change notification settings - Fork 323
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
Runsettings from command line (--) doesnt have capability to pass TestRunParameters #862
Comments
/cc @pvlakshm |
For the above example, can we have something like Currently, if same argument is passed more than once with different values after |
Note that the addition of command line parameters should overlay the file contents passed in through the In this way, you can easily have default test options, but override just a few. |
@harshjain2 Personally, I would rather error than allow multiple overrides in the command line. Odds are if I provided multiple overrides to the same key, I made a mistake. |
Maybe add a flag to indicate intentionally adding multiple values, for example |
It might be better to add testrunparameters as first class parameter in the cmdline.
|
It is adapter specific currently, we should think if other adapters are interested in implementing this behavior (in order to make it first class in vstest.console)? |
Closing; reactivate if still required. |
If you can show me where the unit tests are for related behaviors, and the argument parsing, I will add the feature myself. As a test runner is already a wrapper to a test framework for the purposes of execution, it seems unnecessary to wrap it again, just so I can pass in arguments. As an alternate solution, I have tried environment variables, but they don't seem to make it to the execution context of the test. Thanks in advance for any assistance you can provide @pvlakshm |
It seems like this is still unresolved - why was it closed so hastily? The thing that makes the least sense is how it works right now, which is to simply throw up a random XML error |
So is this possible now? :| |
This still doesn't seem to be possible. Can this issue be reopened? |
I also need to be able to modify TestRunParameters from cmdln. |
Yes pleaaase |
Please make this work! |
For those of you struggling with this, I was able to work around it for configurations. I'm not too thrilled with the pattern, so if anyone has a better answer, I'll gladly switch. The idea is that my test classes can ask for a configuration. Locally, I tend to use the user-secrets. On my build server, I use environment variables. So far, this has helped me:
|
@pvlakshm Why would you close this? This is something alot of people need. (Currently needing to find work arounds for this issue). |
please reopen this. This is crucial for our integration with Azure Dev ops |
???? @pvlakshm |
A little ugly but you could do something along the lines of: Left-hand-side of the '=' can be xpath that needs to resolve to an existing attribute or element.
|
For Azure Dev Ops, we have moved away from dotnet test and started using VSTest. Instead we use a dotnet publish in our build pipeline than in release, we choose a settings file when running our vstest. This is no longer an issue for us. |
Runsetting is an option for me if there's a secure way of storing credentials in it. |
@nohwnd I am using bash on Manjaro Linux
|
@philipreimer I am currently digging into this, what I plan to do is:
This should take care of both of the issues, you as the caller will just have to ensure that you don't run into the parser of the command line you are using, I cannot do anything about that. Which in the case of bash is avoided by using Would be really nice if you helped me test this 🙂 |
@nohwnd I can help testing. I also have one general question: why is the format for passing TestRunParameters the way it is? It seems very complicated. I am not familiar with the internals of the dotnet CLI but wouldn't something like this |
@philipreimer I can't answer that I don't have that context either. I started a new issue on your behalf. I think this might be coming from azdo, or maybe was always like that and was never meant to be used "interactively". I am not sure how soon we will get to the issue. It potentially has a ton of dependencies, and so it will be difficult to change. Thanks for the testing part, I am building dotnet/sdk now, so I am not sure how feasible it will be for you to actually try it on your side 😔 |
@nohwnd since this issue has been closed what is the usual process now? Will your changes be included in the next version of dotnet sdk? Do I have to wait for that and when will that happen? Or is there some preview version I can download? |
Heh, I did not know that GH now matches also part of the message, not just whole line. The fix for this is not complete. |
Right now there is a PR pending with the changes that I've done on vstest side, and I am waiting for them to build and merge, to test a fix that I wrote yesterday for sdk to PR it. Once that PR is merged it will be available via a local sdk build (on windows it's simple you just run build.cmd and then eng/dogfood.cmd, on linux I am not sure yet). And then when sdk inserts into dotnet/installer it will be available to download directly as a pre-release. |
I could not get it to not require any escaping, that would only be possible on Windows via PInvoke, and even that was not 100%. So instead I aimed to make it the same syntax for # cmd
dotnet test -- TestRunParameters.Parameter(name=\"myParam\", value=\"value\")
# powershell
dotnet test --% -- TestRunParameters.Parameter(name=\"myParam\", value=\"value\")
# bash
dotnet test -- TestRunParameters.Parameter\(name=\"myParam\",\ value=\"value\"\) At the moment I am waiting for PR to dotnet/sdk to build to see if I pass their tests. It works locally on my Windows. |
Sorry for bringing that up but bash is not the only shell used on non-windows systems. For example, zsh is the default shell in current macos versions, I think. Will the bash version work in those other shells as well? |
@philipreimer bash was an example. The point is that the syntax should be the same for dotnet vstest, dotnet test and (on windows) vstest.console, no matter how many hops there are. I am aware of zsh, and I hope it will work there as well using the same syntax as in bash, but that depends on the escaping rules that zsh has. There is a merge building in dotnet/sdk so let's hope we can have an installer for that soon. |
@philipreimer I was able to validate this on bash and zsh on Ubuntu (actually Ubuntu 18.4 in WSL2). Download and extract to dotnet folder: mkdir dotnet
wget https://aka.ms/dotnet/net5/dev/Sdk/dotnet-sdk-linux-x64.tar.gz
tar zxvf dotnet-sdk-linux-x64.tar.gz -C dotnet
And then just run it from that folder: /mnt/c/temp/dotnet/dotnet test --no-build -- TestRunParameters.Parameter\(name=\"myParam\",\ value=\"value\ with\ space\"\) |
I am attempting to use the syntax here using cmd.
But when I do, I get the error message:
What (if any) version of .NET Core SDK was this fixed in? |
I installed .NET Core SDK 3.1.202 and tried again. Now I am getting a different error message with the same command on the same test project (also using cmd).
Since I have literally copied and pasted the command from above, it seems like this is a bug of some kind with the latest release. |
This was fixed in the master of dotnet/sdk, so it will be part of the next 5.0 release. Checking with the team to get the simplest way to get it into 3.1 as well. |
The vstest.console part was released in this preview https://www.nuget.org/packages/Microsoft.TestPlatform.TestHost/16.7.0-preview-20200519-01 @NightOwl888 we will have to backport to net3.1.xxx after this proves to be working because the bar is a bit higher there than getting it into master of the current dotnet. So this will take some time till it's released... Can't think of any way to get it to you faster, that would be simpler than using the above escaping workaround. |
Thanks. Since our use case is a test framework library that many others will use, getting it to "us faster" wouldn't help. We can wait for an official release, but it would be great if we can get a notification when that happens so we can add the documentation about the feature as well as the minimum prerequisite version of .NET Core SDK. |
It can be helpful while configuring VsTest step on Azure DevOps.
Please just try to install this nuget to project where is located your .runsettings file |
Description
TestPlatform can handle only those settings which is of the form
by running command
dotnet test -- node1.node2.node3=value
It doesn't have capability to pass attribute and its value for a runsetting element.
for example:
Creating this issue to enhance command line to handle the above scenario.
The text was updated successfully, but these errors were encountered: