user7676403
user7676403

Reputation:

How can I unit test uwp app with NUnit Test

I have no idea on NUnit Test Framework , I have searched for uwp app with nunit test but cant find any example, this is a related article: How to run UWP NUnit tests in with Visual Studio 2015? , but this doesnt make sense to me , what do i need on unit testing uwp app with nunit test framework, packages needed to be install?

Let's Just say I want to unit test a simple method Like Add and Sub:

public int Add(int num1, int num2){
 return num1 + num2;
}

public int Sub(int num1, int num2){
 return num1 - num2;
}

UPDATE: What I did so far is create a unit test app(universal window) then on project.json or reference remove MSTest and replace it with NUnit and NUnit3TestAdapter and here is my UnitTest.cs :

using System;
using NUnit.Framework;

namespace UnitTestProject1
{
    [TestFixture]
    public class UnitTest1
    {
        [Test]
        public void TestMethod1()
        {
            Assert.AreEqual(4, 4);
        }
    }
} 

But it seems to be not reading my Test as a test, what am I missing?

Upvotes: 3

Views: 1403

Answers (1)

ATL_DEV
ATL_DEV

Reputation: 9591

Everything coming from MS is broken these days. Here's one guys struggle to get things working, but it's from a couple of years ago. A bit has changed since then, but currently, only MSTests will work without ripping out your hair.

http://krzyskowk.postach.io/post/unit-tests-in-uwp

Upvotes: 2

Related Questions