2015-11-20 12 views
6

का उपयोग कर मैक ओएस एक्स कंसोल पर परीक्षण चल रहा है मेरे पास एक्समैरिन के साथ मैक्स ओएस एक्स 10.11.1 स्थापित है। मैं, सरल परीक्षण वर्ग लिखा बस पर मैक ओएस एक्स & उबंटू Nunit परीक्षण चलाने के परीक्षण करने के लिए, वर्ग सचमुच एक तरीका है जिसके रिटर्न स्ट्रिंग है:मोनो/नूनिट-कंसोल/4

using System; 

namespace testing_project 
{ 
    public class EmptyClass 
    { 
     public EmptyClass() 
     { 
     } 

     static void Main(string[] args) 
     { 
     } 

     public string helloWorld() 
     { 
      return "Hello World!"; 
     } 
    } 
} 

और मैं अपने EmptyClass परीक्षण करने के लिए एक NUnit वर्ग है:

using System; 
using NUnit.Framework; 

namespace testing_project 
{ 
    [TestFixture] 
    public class EmptyClassTest 
    { 
     [Test] 
     public void testHelloWorld() 
     { 
      EmptyClass empty = new EmptyClass(); 
      Assert.AreEqual ("Hello World!", empty.helloWorld()); 
     } 
    } 
} 

जब मैं इसे एक्समरिन स्टूडियो में चलाता हूं, तो परीक्षण ठीक हो रहा है।

मैं इसे सीएलआई पर कैसे प्राप्त कर सकता हूं?

उत्तर

12

मोनो एक NUnit के धावक/कंसोल (संस्करण 2.4.8) एक खोल स्क्रिप्ट nunit-console कहा जाता है के माध्यम से कहा जाता है कि स्थापित करने में शामिल हैं:

cat `which nunit-console` 
#!/bin/sh 
exec /Library/Frameworks/Mono.framework/Versions/4.2.1/bin/mono --debug $MONO_OPTIONS /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5/nunit-console.exe "[email protected]" 

तो आप या तो कॉल कर सकते हैं CLI से अपने परीक्षण चलाने के लिए NUnit की परीक्षण .csproj या सीआईएल/विधानसभा:

MONO_IOMAP=all nunit-console nunit-lib/nunit-lib.csproj 

या

nunit-console nunit-lib/bin/Debug/nunit-lib.dll 

नोट: एनयूनिट कंसोल 2.4.x को हार्ड-कोडित विंडोज-स्टाइल डायरेक्टरी सेपरेटर के कारण टूटा हुआ है जब .csproj फ़ाइलों को पार्स करते हुए और अपेक्षित सीआईएल/असेंबली स्थान बनाते हैं, तो इसके आसपास काम करने के लिए MONO_IOMAP का उपयोग करें। यह न्यूट रनर 3.0 में कोई मुद्दा नहीं है।

उदाहरण:

nunit-console nunit-lib/bin/Debug/nunit-lib.dll 

NUnit version 2.4.8 
Copyright (C) 2002-2007 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 15.0.0.0 
    CLR Version: 4.0.30319.17020 (4.2.1 (explicit/8862921 Thu Oct 29 17:09:16 EDT 2015)) 

.F 
Tests run: 1, Failures: 1, Not run: 0, Time: 0.687 seconds 

Test Case Failures: 
1) nunitlib.Test.TestCase : Expected string length 8 but was 5. Strings differ at index 0. 
    Expected: "Overflow" 
    But was: "Stack" 
    -----------^ 

nunit-सांत्वना --help

NUnit version 2.4.8 
Copyright (C) 2002-2007 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 15.0.0.0 
    CLR Version: 4.0.30319.17020 (4.2.1 (explicit/8862921 Thu Oct 29 17:09:16 EDT 2015)) 


NUNIT-CONSOLE [inputfiles] [options] 

Runs a set of NUnit tests from the console. 

You may specify one or more assemblies or a single 
project file of type .nunit. 

Options: 
-fixture=STR   Test fixture to be loaded (Short format: -load=STR) 
-run=STR    Name of the test to run 
-config=STR    Project configuration to load 
-xml=STR    Name of XML output file 
-transform=STR   Name of transform file 
-xmlConsole    Display XML to the console 
-output=STR    File to receive test output (Short format: -out=STR) 
-err=STR    File to receive test error output 
-labels     Label each test in stdOut 
-include=STR   List of categories to include 
-exclude=STR   List of categories to exclude 
-domain=X    AppDomain Usage for Tests 
-noshadow    Disable shadow copy when running in separate domain 
-nothread    Disable use of a separate thread for tests 
-wait     Wait for input before closing console window 
-nologo     Do not display the logo 
-nodots     Do not display progress 
-help     Display help (Short format: -?) 


Options that take values may use an equal sign, a colon 
or a space to separate the option from its value. 
+1

बिल्कुल ही बढ़िया! अगर मैं आपको 100 अंक दे सकता हूं। आपका बहुत बहुत धन्यवाद! –

+1

एलओएल, मैं बस और कॉफी ले जाऊंगा ;-) – SushiHangover

 संबंधित मुद्दे

  • कोई संबंधित समस्या नहीं^_^