提取NUnit logc以生成测试手册

时间:2016-12-14 07:51:30

标签: c# unit-testing nunit

我想从我的NUnit案例中提取描述和断言,以便生成测试手册。

示例:

创建帐户

  • 断言ResponseStatus.Message为“OK”
  • 断言User.Name为“名称”
  • 断言国籍是“美国”

代码:

class JobCell: UITableViewCell {
    @IBOutlet weak var performTask: UIButton!
    var actionBlock: (sender: AnyObject?) -> Void?        

    func someFunc() {
       performTask. addTargetself, action: #selector(JobCell.didTapButton(_:)), forControlEvents: .TouchUpInside)
    }

    func didTapButton(sender: AnyObject) {
         actionBlock?(sender)
    }
}

1 个答案:

答案 0 :(得分:0)

您可以为要声明的每个案例创建自己的测试

[Test, Description("Create Account"), Category("Account")]
public void ResponseMessageShouldEqualsOk()
{        
   Assert.That (res.ResponseStatus.Message, Is.EqualTo("OK"), "Account was not created");
}

[Test, Description("Create Account"), Category("Account")]
public void UserNameShouldEqualsName()
{        
   Assert.That (res.User.Name, Is.EqualTo("Name"));
}


[Test, Description("Create Account"), Category("Account")]
public void UserNationalityShouldEqualsUS()
{        
   Assert.That (res.User.Nationality, Is.EqualTo("US"));
}