I've a lot of UnitTests, which are all configure as AnyCPU
. We would like them to run as x64 on the BUILD machine. The build machine is a Jenkins server that runs basically the NUNIT console runner:
C:\nunit-console\nunit3-console.exe path-to-my-solution.sln --config=Debug --agents=1 --process=Separate --result=TestResult.xml;format=nunit2 --timeout=300000 --workers=1
For test purpose I've this Unit Test:
[Test]
public void TestProcess()
{
Assert.AreEqual(Environment.Is64BitProcess, true);
}
On Visual Studio, if I go to Test -> Test Settings -> Default Processor Architecture
, it fails if I select x86, but success if I select x64.
Is there a way to have the same behavior when executing directly the tests throught the nunit3-console.exe
WITHOUT changing the platform in the test project(not the goal of discussing it here, let's just admit we have some reason to keep it as "Any CPU").
I've found this https://msdn.microsoft.com/en-us/library/ee782531.aspx which explains that to do this on Visual studio, we can either choose my approach, either choose to create a test.runsettings
.
I tried to create a test.runsettings
file, with the following content:
<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
<!-- Configurations that affect the Test Framework -->
<RunConfiguration>
<!-- [x86] | x64
- You can also change it from menu Test, Test Settings, Default Processor Architecture -->
<TargetPlatform>x64</TargetPlatform>
</RunConfiguration>
</RunSettings>
I've put it in the root of my solution and I've done the Test -> Test Settings -> Select Test Settings file
.
The weird part is that I've the feeling that this operation (setting this file as "Test Settings file" is not persisted when I commit, because after having done it if I take my latest changes on another computer, I've to set it again.
But my UnitTest still fails on the build machine. Any idea of an alternative or what I've done wrong here?