Build/Test Issues

GetHashCode Nrunch vs Nunit different values

Started by supertom44 on 5,934 views

Hi all,

I am currently evaluating Ncrunch to see if it is a viable solution for my needs and I have come across a strange problem.

When requesting the hashcode of a string Ncrunch returns a different value in the test when compared to running the test in Nunit/ReSharper itself.

Here is an example of a test that fails with Ncrunch but passes with Nunit:

[Test]
public void Test()
{
Assert.That(1099313834, Is.EqualTo("abc".GetHashCode()));
}


We are running:
ReSharper: 5.1 (NUnit version 2.5.7)
Ncrunch: 2.5.0.12
Standalone NUnit: 2.6.2
.Net 4 Framework

Cheers
Hi,

Thanks for posting. This is most likely due to a different in the processor architecture of the hosting process. There is a lack of standardisation around X86/X64 between test runners - please read this documentation page for more information. You can confirm whether the issue is X86/X64 based by comparing IntPtr.Size between test runs.
Hi,

Many thanks for your reply, IntPtr.Size does indeed differ between the two, I get 8 with ReSharper and 4 with NCrunch.

We have read the article you linked us to and we have tried changing the architecture but we are still unable to solve this issue.
Hi,

It seems as though your test project has been designed to only work with an X64 architecture.

So to me it makes sense for you to change the processor architecture in the build configuration for this project to X64. In this way, there's no way the project can be loaded in an X86 architecture. NCrunch will detect this and will run as X64.

Can you describe the problem you're experiencing right now? Does changing the architecture as you have done not have any effect on the process? (i.e. is it still launching as X86?)

Post a reply

Log in to reply.