当TestCase运行时需要进行调试,但是case的代码非常多,并不想或则没发打开所有项目进行调试,只需要调试某个Case即可.

添加下面代码到case的初始化中,设置ISDEBUG变量=true,在运行case时,会提示进行进行调试,附加相关进程,点击确定即可进行调试.

 

当然也可以应用到其他的应用程序中,不一定为Testcase.

 

  public static bool IsDebugging
        {
            get
            {
                string s = Environment.GetEnvironmentVariable("ISDEBUG");
                bool result = false;
                if (bool.TryParse(s, out result))
                {
                    return result;
                }
                return false;
            }
        }

        public static void DebugPrompt(string msg)
        {
            if (IsDebugging)
            {
                int procId = System.Diagnostics.Process.GetCurrentProcess().Id;
                MessageBox.Show(
                   string.Format("ISDEBUG 已设置,测试现处在 '{0}'\n需要附加的进程ID为: {1}", msg, procId),
                   "Debugging: " + procId,
                   MessageBoxButtons.OK,
                   MessageBoxIcon.Exclamation,
                   MessageBoxDefaultButton.Button1,
                   MessageBoxOptions.RightAlign);
            }
        }

相关文章:

  • 2022-12-23
  • 2021-07-25
  • 2022-12-23
  • 2021-12-18
  • 2022-01-03
  • 2021-07-19
  • 2022-12-23
猜你喜欢
  • 2021-09-05
  • 2021-05-15
  • 2022-12-23
  • 2021-05-17
  • 2022-01-28
  • 2021-11-27
  • 2021-11-05
相关资源
相似解决方案