Vstest: Custom arguments with `dotnet vstest`

Created on 29 Nov 2018  路  6Comments  路  Source: microsoft/vstest

Description

Cant read the custom args that send via dotnet vstest command.

Steps to reproduce

Running the command dotnet vstest Test.dll -- arg1=val1 arg2=val2
Read the arguments arg1 and arg2 with the TestContext.Properties or Environment.GetCommandLineArgs but non of them contains those arguments.

Expected behavior

Able to read val1 and val2 from TestContext.Properties or Environment.GetCommandLineArgs

Actual behavior

Both TestContext.Properties and Environment.GetCommandLineArgs do not contains those arguments.

Environment

.Net Core 2.1 and .Net Core 2.1

enhancement

Most helpful comment

@singhsarab I have below scenario.

I want to run Selenium based UI tests using mstest tasks in Azure pipeline. Need to configure multiple browsers testing for the same set of test cases. Plan to create separate test task for each browser, which uses the same test code but with browser name passed at run time. I thought of passing browser name in command line and read it from TestContext in code. But it seems not getting those command line parameters. I tend to see same behaviour was available with .Net framework but not with core.

Any lead on this?

All 6 comments

@PBoraMSFT @cltshivash Please triage this.

Is that is an enhancement?? How should we read these custom arguments inside the tests?

@rhalaly This is a new ask, hence has been marked as an enhancement.

Can you please elaborate your problem, we will then be able to provide you with the guidance.

@singhsarab I have below scenario.

I want to run Selenium based UI tests using mstest tasks in Azure pipeline. Need to configure multiple browsers testing for the same set of test cases. Plan to create separate test task for each browser, which uses the same test code but with browser name passed at run time. I thought of passing browser name in command line and read it from TestContext in code. But it seems not getting those command line parameters. I tend to see same behaviour was available with .Net framework but not with core.

Any lead on this?

@singhsarab

Documentation says [args] should be supported, but seems like it's still not working.

Could you please clarify on this?

I hope this PR should help. We have added the support for add/overriding TestRunParameters

PR: https://github.com/microsoft/vstest/pull/2251

Was this page helpful?
0 / 5 - 0 ratings