How can I unit test a 64-bit .NET 4.7 project?

559 Views Asked by At

I first got a BadImageFormatException in my test project and after some research it seemed that it was caused because the test project had a AnyCPU build, while the project I want to test had a 64-bit build. After changing my test project to 64 bit the tests stopped working all together. Their icons stays the blue circle with exclamation point after I select run all and when I select one it just show the source file and line number of the test.

I'm using Microsoft.VisualStudio.TestTools.UnitTesting for unit testing.

How can I get my test project to work?

I even threw it away and made a completely new test project and that still got the same error.

1

There are 1 best solutions below

0
On BEST ANSWER

As described in https://learn.microsoft.com/en-us/visualstudio/test/run-a-unit-test-as-a-64-bit-process?view=vs-2017 given by Lex Li, I selected Tests in the VS menu, selected Test Settings, selected Default Processor Architecture and changed to x64. After that it worked.

enter image description here