zoukankan      html  css  js  c++  java
  • 单元测试中方法运行测试和调试测试不起作用原因

    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

     

  • 相关阅读:
    [树状数组]JZOJ 4658 小Z调顺序
    [差分数组]JZOJ 3187 的士
    [BFS]JZOJ 4671 World Tour
    [BFS]JZOJ 4672 Graph Coloring
    [数学]JZOJ 4673 LCS again
    shell:正则表达式和文本处理器
    开发脚本自动部署及监控
    Linux中的重启命令
    nginx和nfs
    网络相关配置
  • 原文地址:https://www.cnblogs.com/wgx0428/p/4476988.html
Copyright © 2011-2022 走看看