zoukankan
html css js c++ java
nunit的最精简教程
可能要用到。
Code
using
System;
using
NUnit.Framework;
namespace
NUnit
{
class
Program
{
static
void
Main(
string
[] args)
{
}
}
[TestFixture]
//
声明类中包含测试
public
class
TestCalculator
{
//
公用的变量要写在外面避免重复
private
Calculator Cal;
private
int
a;
private
int
b;
[SetUp]
protected
void
SetUp()
{
a
=
2
;
b
=
4
;
Cal
=
new
Calculator();
}
[Test]
public
void
SumTest()
//
测试方法推荐不带参数
{
Assert.AreEqual(
6
, Cal.Sum(a, b));
}
[Test]
[ExpectedException(
typeof
(DivideByZeroException))]
[Ignore(
"
Not yet !
"
)]
//
完全忽略;[Explicit]是还可以手动执行的
public
void
DivTest()
{
int
c
=
0
;
Cal.Div(a, c);
Assert.Fail(
"
Got an expection !
"
);
}
//
[TestFixtureSetUp][TestFixtureTearDown]共享和清除昂贵的资源(db)
//
[Suite] case和其他suite的容器(支持级联的集合类)
//
[Category]用于case分类,cmd中用include和exclude实现
//
测试生命周期合约:
}
//
用反射得到类结构,然后用Attribute规划测试。
//
目标类要public且有默认的构造函数(不要有副作用),否则nunit无法识别或构造。
public
class
Calculator
{
public
int
Sum(
int
a,
int
b)
{
return
a
+
b;
}
public
int
Div(
int
a,
int
b)
{
return
a
/
b;
}
}
}
查看全文
相关阅读:
改变oracle数据库归档模式_译文
改变数据库归档模式
oracle状态
oracle开启一个用户
plsql中文乱码问题方案解决
mybatis 和hibernate的区别
jquery
servlet 相应头重定向
自定义鼠标右键
关于select input(选中,取值,赋值等)--------方便自己查阅
原文地址:https://www.cnblogs.com/hbreset/p/1279313.html
最新文章
php语法
点击图片,上传文件样式
mail 的配置
angular style, class
angular controller
angular directive =,&
angular
chrome dev 开发工具
2021年3月9
2021年3月8
热门文章
2021年3月7
2021年3月6
2021年3月5
2021年3月4
2021年3月3
2021年3月2
2021年3月1
2021年2月28
oracle temporary table
windowsxp_电脑桌面显示不出来。
Copyright © 2011-2022 走看看