Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run vstest.console.exe for Unit Test 64-bit platform

How to run vstest.console.exe targeting the 64-bit platform?

Unit Tests set to target platform x64 were failing to run on DevOps tools (VSTS/TeamCity/Octopus).

[error]Error: None of the provided test containers match the Platform Architecture and .Net Framework settings for the test run.

Platform: X86 .Net Framework: Framework45. Go to http://go.microsoft.com/fwlink/?LinkID=330428 for more details on managing these settings.

like image 680
Alexz Avatar asked Apr 26 '17 14:04

Alexz


People also ask

How to run vstest on x64?

Locally it is achieved by setting the tests on Visual Studio to run on x64 as default process. Testtab on VS > Test Settings> Default Process Architecture> x64 When using some DevOps tool, the platform can be specified in the script which runs the vstest.console.exe

Should I use 64-bit or x64 for unit testing?

There's no advantage to compiling test projects with the 64-bit configuration, unless you are calling code that is only supported on 64-bit. Set the unit tests to run as a 64-bit process. From the Visual Studio menu, choose Test, then choose Processor Architecture for AnyCPU projects. Choose x64 to run the tests as a 64-bit process.

What is the difference between MSTest and vstest?

MSTest.exe - You can use the MSTest.exe program to run automated tests in a test assembly from a command line. This is a legacy tool. VSTest.Console.exe - This is the latest offering from Microsoft to run automated unit and coded UI tests from a command line. VSTest.Console.exe is optimized in performance and can be used in place of MSTest.exe.

What is run in isolation in vstest?

Runs the tests in an isolated process. This isolation makes the vstest.console.exe process less likely to be stopped on an error in the tests, but tests might run slower. This option makes the vstest.console.exe process use or skip the VSIX extensions installed (if any) in the test run.


2 Answers

Locally it is achieved by setting the tests on Visual Studio to run on x64 as default process.

Test tab on VS > Test Settings > Default Process Architecture > x64

When using some DevOps tool, the platform can be specified in the script which runs the vstest.console.exe

In my case, I'm using Azure DevOps Build Definitions, so I set my VS Test task to /platform:x64 through a parameter when running vstest.console.exe.

vstest.console.exe "C:\Project\bin\x64\Release\Project.UnitTests.dll" "C:\Project\bin\x64\Release\Project.UnitTests.dll" /platform:x64 /logger:trx

Once it is set, all x64 targeting Unit Tests dlls will execute successfully.

like image 166
Alexz Avatar answered Oct 07 '22 18:10

Alexz


Check if you have vstest.console.exe under C:\ Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Mi crosoft\TestWindow\

  • from cmd go to the path where your projects dll are kept. i.e. cd C:\Users\krakhil\Desktop\Notes\Practice Codes\VerifyExe\VerifyExe\bin\Debug

Press Enter

Then write -> "C:\ Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Mi crosoft\TestWindow\vstest.console.exe" VerifyExe.dll

Where VerifyExe.dll is the project dll i want to execute.

like image 29
KR Akhil Avatar answered Oct 07 '22 19:10

KR Akhil