0
votes

I am trying to execute CodedUI Tests from TeamCity using MSTest Runner. To execute CodedUI Tests, I installed Visual Studio Test Agent on TeamCity Server and configured build step with MSTest.

Below is the error log.

Step 5/5: Execute CodedUI Test (MSTest) (1s)  
[18:31:25]Starting: C:\BuildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit  
[18:31:25]in directory: C:\BuildAgent\work\1a7958057951b685
[18:31:27]2015-01-02 18:31:27,536 [58756] ERROR JetBrains.BuildServer.NAntLoggers.NUnitLauncher2 - Failed to start process. Access is denied. Path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, arguments: /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.UnitTests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.Tests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.CodedUITests\bin\CI\MobileSecurityAppCodedUITests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.Tests\bin\CI\BitwiseMobile.Tests.dll /resultsfile:C:\TeamCity\temp\buildTmp\tmp1BB9.tmp.teamcity.trx, at C:\BuildAgent\work\1a7958057951b685  
[18:31:27]System.Exception: Failed to start process. Access is denied. Path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, arguments: /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.UnitTests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.Tests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.CodedUITests\bin\CI\MobileSecurityAppCodedUITests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.Tests\bin\CI\BitwiseMobile.Tests.dll /resultsfile:C:\TeamCity\temp\buildTmp\tmp1BB9.tmp.teamcity.trx, at C:\BuildAgent\work\1a7958057951b685 ---> System.ComponentModel.Win32Exception: Access is denied
[18:31:27]   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
[18:31:27]   at System.Diagnostics.Process.Start()
[18:31:27]   at JetBrains.TeamCity.Utils.ProcessRunnerBase.Run(ProcessStartInfo psi) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\ProcessRunnerBase.cs:line 61
[18:31:27]   --- End of inner exception stack trace ---
[18:31:27]   at JetBrains.TeamCity.Utils.ProcessRunnerBase.Run(ProcessStartInfo psi) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\ProcessRunnerBase.cs:line 65
[18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Execute(IRunProcess proc) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 123
[18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Run(String executable, PlatformVersion env, PlatformType platform, EnvironmentArg[] envKeys, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 58
[18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, EnvironmentArg[] additionalEnvironment, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 49
[18:31:27]   at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 41
[18:31:27]   at JetBrains.TeamCity.Utils.Runtime.RunInRuntime.ForkInRuntime(PlatformVersion version, PlatformType type, String executable, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\RunInRuntime.cs:line 50
[18:31:27]   at JetBrains.TeamCity.NUnitCommon.PlugableRunFactory.RunProcessAsPlugable.Run() in c:\BuildAgent\work\42f5b4bce579465c\src\TestRunnerCommon\src\PlugableRunFactory.cs:line 33
[18:31:27]   at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.ExecuteTasks(ITestRunArguments arguments, IPlugableTestRunner[] plugRuns) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 136
[18:31:27]   at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run2(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 114
[18:31:27]   at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 57
[18:31:27]Failed to start process. Access is denied. 
    Path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, arguments: /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.UnitTests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.UnitTests\bin\CI\BitwiseMobile.Tests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.CodedUITests\bin\CI\MobileSecurityAppCodedUITests.dll /testcontainer:C:\BuildAgent\work\1a7958057951b685\src\BitwiseMobile.Tests\bin\CI\BitwiseMobile.Tests.dll /resultsfile:C:\TeamCity\temp\buildTmp\tmp1BB9.tmp.teamcity.trx, at C:\BuildAgent\work\1a7958057951b685 
    at JetBrains.TeamCity.Utils.ProcessRunnerBase.Run(ProcessStartInfo psi) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\ProcessRunnerBase.cs:line 65
    at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Execute(IRunProcess proc) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 123
    at JetBrains.TeamCity.Utils.Runtime.ProcessRun.Run(String executable, PlatformVersion env, PlatformType platform, EnvironmentArg[] envKeys, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 58
    at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, EnvironmentArg[] additionalEnvironment, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 49
    at JetBrains.TeamCity.Utils.Runtime.ProcessRun.RunWithCommandLine(PlatformVersion env, PlatformType platform, String assembly, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\ProcessRun.cs:line 41
    at JetBrains.TeamCity.Utils.Runtime.RunInRuntime.ForkInRuntime(PlatformVersion version, PlatformType type, String executable, String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\Utils\src\Runtime\RunInRuntime.cs:line 50
    at JetBrains.TeamCity.NUnitCommon.PlugableRunFactory.RunProcessAsPlugable.Run() in c:\BuildAgent\work\42f5b4bce579465c\src\TestRunnerCommon\src\PlugableRunFactory.cs:line 33
    at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.ExecuteTasks(ITestRunArguments arguments, IPlugableTestRunner[] plugRuns) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 136
    at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run2(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 114
    at JetBrains.BuildServer.NAntLoggers.NUnitLauncher2.Run(String[] args) in c:\BuildAgent\work\42f5b4bce579465c\src\NUnitBootstrap\src\NUnitLauncher2.cs:line 57
[18:31:27]Process exited with code -1
[18:31:27]Step Execute CodedUI Test (MSTest) failed

I tried giving all possible permissions to the MSTest folder, but still its not working. I could run the MSTest.exe from command prompt but not through TeamCity.

2
From the errors it looks like access is denied to something at the path: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE, and it's trying to start a process from there. It's possible that the specific user TeamCity is running under will need permission to access the given path and possibly local security policy permission to run processes non-interactively.Nanhydrin
I also tried giving permission to everyone on this folder but its still not working. Also tried copying MSTest.exe to TeamCity agents folder but still the same issue.Priyanka
Have a look at this thread The relevant bit is: It ended up being the wild card path I entered to say which test dll's to run. It didn't like *.dll but did work with **/bin/Release/*.Test.dll Yet both produced the same arguments listed in the logs. The worst part is the error is extremely misleading. I didn't figure it out until I ran C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.NUnitLauncher.exe #TeamCityImplicit from the command line and Googled the error it posted.Nanhydrin
Tried that as well. Still no luck.Priyanka

2 Answers

1
votes

I've had the same issue when trying to set up a custom MSTest.exe path (as TeamCity 7 doesn't support MS Test 2013). It turned out that you will have to provide the full path to the MSTest.exe including the file name.

So instead of

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\

you must use

C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe

Of ocurse that's just a sample, you might have to change that according to the MS Test version that you are using.

0
votes

For anyone else having issues with this, removing the system.MSTest.xxx parameter that teamcity had created, fixed this for me.