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

     

  • 相关阅读:
    mysql总结
    JVM入门_笔记_狂神说
    spring-与事务管理相关的工具类
    spring-获取连接的工具类
    浏览器调试之 实时更新 browser-sync
    Git: 版本控件
    Visual Studio Code 自定义快捷键,自动生成.vue文件
    Markdown基本语法
    Node.js 平台-服务器 之 Express
    chrome插件之 vue devtools
  • 原文地址:https://www.cnblogs.com/wgx0428/p/4476988.html
Copyright © 2011-2022 走看看