1

I created a project in Visual Studio for unit testing using the nuget package of nunit. The test runs well in Visual Studio using the test explorer, but i Need to run them using the nunit3 console.

My project is very simple I:

  • Created a console project in C#
  • I Installed Nunit and NUnitTestAdapter using NuGet Package Manager.
  • I create a class called MyMath.cs with the next code:

    namespace NunitDemo
    {
    class MyMath
    {
        public int add(int a, int b)
        {
            return a + b;
        }
    
        public int sub(int a, int b)
        {
            return a - b;
        }
    }
    }
    
  • I create a MyTestCase Class with the following code to test MyMath methods:

    using NUnit.Framework;
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace NunitDemo
    {
        [TestFixture]
        class MyTestCase
        {
            [TestCase]
            public void Add()
            {
               MyMath math = new MyMath();
               Assert.AreEqual(31, math.add(20, 11));
            }
    
            [TestCase]
            public void Sub()
            {
            MyMath math = new MyMath();
            Assert.AreEqual(9, math.sub(20, 11));
            }
        }
    }
    
  • I rebuild my solution and using The test explorer panel I can run my test in Visual Studio without problems.

But I need to run my test using the nunit3-console prompt, So, How Can I generate (Or Where Is) a DLL file to run test from the console o using nunit-gui?

I search inside C:\Users\Manuel\source\repos\ConsoleAppForNunit\ConsoleAppForNunit\bin\Debug but there is not a suitable .DLL

There is a Screenshot of that path: enter image description here

Eduardo Corona
  • 1,262
  • 4
  • 20
  • 31

1 Answers1

1

From what you describe, you have never installed the NUnit Console application. You can find it in various places...

  1. If you use chocolatey, use the choco command-line utility to install nunit-consolerunner.

  2. If you prefer to have it installed in a project directory, install NUnit.ConsoleRunner from nuget.org. You can do this within visual studio.

  3. You can download the files from the project site at https://github.com/nunit/nunit-console

Charlie
  • 12,928
  • 1
  • 27
  • 31