How to pass a context parameter value to a web test from MTM
-
29. února 2012 16:24
I have a test case with an associated automation (a webtest) and I need to run the same test case on different web servers. I have a context parameter in the webtest to hold the url (URL_VALUE)
I have no problems running the webtest from command line using MSTest.exe and initializing the environment variable using Test.URL_VALUE=<url value>
But now I need to do the same but using Test Manager instead, is there any way of using the test case parameters to accomplish this? Or any other way of passing values to a webtest?
Thanks in advance
Všechny reakce
-
1. března 2012 6:19
You will need a physical or virtual environment to run automated tests from MTM http://msdn.microsoft.com/en-us/library/dd553270.aspx
You can then use environment variables in the same way on those machines as you described above.
Thanks,
Anuj
http://www.anujchaudhary.com
-
1. března 2012 10:35
Hi Anuj,
I have a physical environment to run the test cases, my doubt is how to set the environment variables in the test agent using Test Manager.
Should I execute a script before the automated test run which sets the env. variables? (i.e. using the test settings and a script that executes the shell commands to set the env. variables?)
-
3. března 2012 19:43
Yes executing it as a Pre script in Test Settings would be a good idea.
Thanks,
Anuj
http://www.anujchaudhary.com
-
5. března 2012 16:08
Hi Anuj,
I tryed to set the environment variables in the pre script but it doesn't work (I'm using a batch file to set the env. variables.)
I view this in the qtsetup.bat file:
REM ****************************************************************************
REM * Generated by Microsoft Visual Studio
REM * Copyright (c) Microsoft Corporation. All rights reserved.
REM *
REM ****************************************************************************
set DeploymentDirectory=C:\TFS\v1\Dev\v1.23.BugFixes\Testing\Automation\TestResults\mdescalzi_LAPTOP032 2012-03-05 15_53_48\Out
set DataCollectionEnvironmentContext=Microsoft.VisualStudio.TestTools.Execution.DataCollectionEnvironmentContext
set TestRunDirectory=C:\TFS\v1\Dev\v1.23.BugFixes\Testing\Automation\TestResults\mdescalzi_LAPTOP032 2012-03-05 15_53_48
....more set entries...
set ControllerName=LAPTOP032
set TestDeploymentDir=C:\TFS\v1\Dev\v1.23.BugFixes\Testing\Automation\TestResults\mdescalzi_LAPTOP032 2012-03-05 15_53_48\Out
REM ****************************************************************************
REM * User Commands
REM *
REM ****************************************************************************
set URL_VALUE=https://sctest.test.int
But the context parameter URL_VALUE is empty when my web test executes.
I tryed this other syntax but it failed too:
set Test.URL_VALUE=https://sctest.test.int
What else can I try?
Thanks
-
23. března 2012 10:07
Finally I wrote a web test plugin that runs before the web test (PreWebTest event).
It reads from a file deployed within the test settings and then inside the plug-in read from that file and set the context variables. (the downside is that I need to have a different test setting per web server)
Thanks
- Označen jako odpověď mdescalzi 23. března 2012 10:07
-
15. května 2012 10:47Your plugin sounds handy, can we get hold of it?