博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何使用NUnit
阅读量:6931 次
发布时间:2019-06-27

本文共 1034 字,大约阅读时间需要 3 分钟。

 

获取NUnit

1.下载安装包

从github上下载安装包 NUnit.3.4.1.msi

 

在项目中添加引用

C:\Program Files (x86)\NUnit.org\framework\3.4.1.0\net-4.5\nunit.framework.dll

 

2.直接通过NuGet获取

 

使用方法

TestFixture Attribute

在类上面使用

 

SetUp Attribute

在上面的类的方法上使用

 

 

SetUpFixture Attribute

和多个TestFixture平级,比如类A和类B标记为TestFixture。然后类C添加SetUpFixture

This is the attribute that marks a class that contains the one-time setup or teardown methods for all the test fixtures under a given namespace.

The class may contain at most one method marked with the OneTimeSetUpAttribute and one method marked with the OneTimeTearDownAttribute.

 

 

 

 

using NUnit.Framework;namespace ConsoleApp{    [TestFixture]    public class KataTests    {        [Test]        public void BasicTests()        {            Assert.AreEqual("01011110001100111", Kata.FakeBin("45385593107843568"));            Assert.AreEqual("101000111101101", Kata.FakeBin("509321967506747"));            Assert.AreEqual("011011110000101010000011011", Kata.FakeBin("366058562030849490134388085"));        }    }}

 

 

考虑全局执行一次的函数

比如整个项目加载日志模块,只需要加载一次

转载地址:http://wwvjl.baihongyu.com/

你可能感兴趣的文章
数据库读写分离
查看>>
数据库MySQL,Mongodb,Redis及Zookeeper集群搭建文档
查看>>
阿里腾讯平安三马之后,跳出黑马-飞贷
查看>>
自制mysql主从复制(实时)软件——设计
查看>>
我的友情链接
查看>>
Android控件ListView优化
查看>>
blackberry针对Microsoft Exchange综合介绍
查看>>
我的友情链接
查看>>
部署java后台运用
查看>>
CentOS使用CDROM作为yum的源
查看>>
解决fiddler无法抓取localhost数据的问题
查看>>
Linux运维不可不知的性能监控和调试工具
查看>>
Xamarin iOS编写第一个应用程序创建工程
查看>>
【2】iptables理解 - 总体印象
查看>>
Xamarin.Android编译CPU类型选择方式
查看>>
XAML数据绑定(Data Binding)
查看>>
服务器SSL/TLS快速检测工具TLLSSLed
查看>>
Ext分区文件恢复工具extundelete
查看>>
linux学习笔记
查看>>
redis 初级设置
查看>>