首页 > 其他 > 详细

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

时间:2015-05-04 20:01:30      阅读:247      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!