你的位置:首页 > 软件开发 > ASP.net > mvc+webapi 单元测试

mvc+webapi 单元测试

发布时间:2016-04-09 23:00:19
1.前言    现在这个项目已经有阶段性的模块完成了,所以就想着对这些模块进行单元测试,以保证项目的代码的质量。首先虽然标题是mvc+webapi实质上我只是对mvc进行的测试。用的时候vs的unit test generator.至于它的安装和介绍在这不做详细介绍。好的现在开始 ...

 1.前言

    现在这个项目已经有阶段性的模块完成了,所以就想着对这些模块进行单元测试,以保证项目的代码的质量。首先虽然标题是get='_blank'>mvc+webapi实质上我只是对mvc进行的测试。用的时候vs的unit test generator.至于它的安装和介绍在这不做详细介绍。好的现在开始总结我的单元测试总结。

2.单元测试建立

  2.1新建单元测试项目

mvc+webapi 单元测试

mvc+webapi 单元测试mvc+webapi 单元测试
[TestClass]  public class mtnfim  {    //实例化测试mvc Controller     mgtController mtn_fim = new mgtController();    [TestMethod]    public void IndexTest()    {      //调用类中方法      var ret = mtn_fim.Index() as ViewResult;      int errcode = testresult.action_result(ret).errcode;      Assert.AreEqual(0, errcode);    }}

原标题:mvc+webapi 单元测试

关键词:web

web
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。