Condividi tramite


Run a unit test as a 64-bit process

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

If you have a 64-bit machine, you can run unit tests and capture code coverage information as a 64-bit process.

To run a unit test as a 64-bit process

  1. If your code or tests were compiled as 32-bit/x86, but you now want to run them as a 64-bit process, recompile them as Any CPU.

    Alternatively, In Visual Studio 2017, you could also compile your project as 64-bit.

    Tip

    For maximum flexibility, compile your test projects with the Any CPU configuration. Then you can run on both 32-bit and 64-bit agents. 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.

  2. Set the unit tests to run as a 64-bit process.

    From the Visual Studio menu, choose Test, then choose Test Settings, and then choose Processor Architecture. Choose x64 to run the tests as a 64-bit process.

    - or -

    Specify <TargetPlatform>x64</TargetPlatform> in a .runsettings file. An advantage of this method is that you can specify groups of settings in different files and quickly switch between different settings. You can also copy settings between solutions. For more information, see Configure unit tests by using a .runsettings file.

See also