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

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

 

 

 

 

转载于:https://www.cnblogs.com/wgx0428/p/4476988.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值