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

     

  • 相关阅读:
    shell中$0,$?,$!等的特殊用法【转载】
    Hadoop操作hdfs的命令【转载】
    libevent的简单应用【转载】
    使用GDB生成coredump文件【转载】
    常用的js代码
    强大的promise
    循环的N种写法
    原型与继承与class
    模块化
    正则RegExp
  • 原文地址:https://www.cnblogs.com/wgx0428/p/4476988.html
Copyright © 2011-2022 走看看