c# - 如何使用 NUnit Test 对 uwp 应用程序进行单元测试

标签 c# unit-testing uwp nunit

我对 NUnit 测试框架一无所知,我用 nunit 测试搜索了 uwp 应用程序,但找不到任何示例,这是一篇相关文章:How to run UWP NUnit tests in with Visual Studio 2015? ,但这对我来说没有意义,我需要用 nunit 测试框架对 uwp 应用程序进行单元测试,需要安装什么包?

假设我想对一个简单的方法(如 Add 和 Sub)进行单元测试:

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

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

更新:到目前为止我所做的是创建一个单元测试应用程序(通用窗口) 然后在 project.json 或引用中删除 MSTest 并将其替换为 NUnitNUnit3TestAdapter 这是我的 UnitTest.cs :

using System;
using NUnit.Framework;

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

但它似乎没有将我的测试作为测试阅读,我错过了什么?

最佳答案

这些天来自 MS 的一切都坏了。这里有一个人正在努力让事情正常进行,但那是几年前的事了。从那时起发生了一些变化,但目前,只有 MSTests 可以工作而不会扯掉你的头发。

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

关于c# - 如何使用 NUnit Test 对 uwp 应用程序进行单元测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46379761/

相关文章:

javascript - 使导入的函数使用新变量

c# - 什么会导致 WCF 服务返回类型为 "object"的对象

c# - 无法在 VS 2017 中使用 C# 6.0 功能

android - 如何更好地在 Android 上对 Looper 和 Handler 代码进行单元测试?

c# - 如何在 FluentAssertions 中对集合中的属性使用 Exclude?

windows - (UWP) 从 Assets 文件夹获取 xml 文件

c++ - 检测到 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker' : value '1' doesn't match value '0' in msvcrtd. 库不匹配

c# - UWP Windows 10 未触发 OnSuspending 事件

c# - WPF DataGrid 列标题使用自定义样式调整大小

C# ASP X-CONTENT-TYPE-OPTIONS - Internet Explorer 不显示 PNG 文件