码迷,mamicode.com
首页 > 其他好文 > 详细

单元测试中方法运行测试和调试测试不起作用原因

时间:2015-05-04 20:02:23      阅读:299      评论:0      收藏:0      [点我收藏+]

标签:

1.方法上右键运行测试和调试测试不起作用代码:

 1         #region 我的相册
 2         /// <summary>
 3         /// 我的相册
 4         /// </summary>
 5         /// <param name="currIndex"></param>
 6         /// <param name="PageSize"></param>
 7         [TestMethod]
 8         public void MyPicList(int currIndex, int PageSize)
 9         {
10             int result = 0;
11             try
12             {
13                 //测试逻辑
14                 string str = "我靠";
15                 Console.WriteLine(str);
16             }
17             catch (Exception)
18             {
19                 result = 1;
20             }
21             Assert.AreEqual(0, result);
22         } 
23         #endregion

纠结了一下午后以为vs哪块出问题了,试了各种办法。最后在看一篇单元测试博文的时候,看到

测试方法的要求:必须要有TestMethod注解,返回类型必须为void,并且不能有参数这句话顿时幡然醒悟。

正确代码:

 

 1         #region 我的相册
 2         /// <summary>
 3         /// 我的相册
 4         /// </summary>
 5         /// <param name="currIndex"></param>
 6         /// <param name="PageSize"></param>
 7         [TestMethod]
 8         public void MyPicList()
 9         {
10             int result = 0;
11             try
12             {
13                 //测试逻辑
14                  string str = "我靠";
15                 Console.WriteLine(str);
16             }
17             catch (Exception)
18             {
19                 result = 1;
20             }
21             Assert.AreEqual(0, result);
22         } 
23         #endregion

 

 

 

 

单元测试中方法运行测试和调试测试不起作用原因

标签:

原文地址:http://www.cnblogs.com/wgx0428/p/4476988.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!