如何在 MacOS 上 运行 64 位 nunit 测试?

How to run nunit test in 64bit on MacOSX?

我有一个程序集需要在 64 位进程中 运行,但我无法使其在 nunit 运行ner 中工作。

我创建了一个测试代码,非常简单,只需在 main 函数和 nunit 测试函数中打印出指针大小:

using System;
using NUnit.Framework;

namespace PtrSize
{
    class MainClass
    {
        [Test]
        public static void Test()
        {
            Console.WriteLine ("IntPtr.Size                : {0}", IntPtr.Size);
            Console.WriteLine ("Environment.Is64BitProcess : {0}", Environment.Is64BitProcess);
        }

        public static void Main (string[] args)
        {
            Console.WriteLine ("IntPtr.Size                : {0}", IntPtr.Size);
            Console.WriteLine ("Environment.Is64BitProcess : {0}", Environment.Is64BitProcess);
        }
    }
}

然后我做了以下测试:

首先我确认单声道是 64 位内置的

Build-Agent-Mac-01s-iMac:Debug BA-Mac-01$ ~/sandbox/mono64/bin/mono --version
Mono JIT compiler version 3.10.0 (tarball Thu Jan  8 09:23:28 CET 2015)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
    TLS:           normal
    SIGSEGV:       altstack
    Notification:  kqueue
    Architecture:  amd64
    Disabled:      none
    Misc:          softdebug 
    LLVM:          supported, not enabled.
    GC:            sgen

然后我用这个单声道运行我的测试程序,它是64位进程:

Build-Agent-Mac-01s-iMac:Debug BA-Mac-01$ ~/sandbox/mono64/bin/mono PtrSize.exe
IntPtr.Size                : 8
Environment.Is64BitProcess : True

然后我用nunit test 运行ner来运行它,一直是32位模式,我也试过nunit-console-x86.exe,还是不行'帮不上忙

Build-Agent-Mac-01s-iMac:Debug BA-Mac-01$ ~/sandbox/mono64/bin/mono ~/Downloads/NUnit-2.6.4/bin/nunit-console.exe PtrSize.exe
NUnit-Console version 2.6.4.14350
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment - 
   OS Version: Unix 14.5.0.0
  CLR Version: 2.0.50727.1433 ( Mono 3.5 ( 3.10.0 (tarball Thu Jan  8 09:23:28 CET 2015) ) )

ProcessModel: Default    DomainUsage: Single
Execution Runtime: mono-3.5
.IntPtr.Size                : 4
Environment.Is64BitProcess : False

Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.0132951 seconds
  Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0

有人对这个问题有想法吗?

从 Mono 4.2.1 开始,安装程序包括 64 位版本的 mono。不幸的是,nunit-console 命令仍然 运行 是 32 位的。

要运行nunit-console为64位,还是需要使用mono64命令:

mono64 /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5/nunit-console.exe <path to dll>