简体   繁体   English

需要用于MS UI自动化的源代码dll的代码覆盖信息

[英]Need Code coverage info of Source code dlls for MS UI automation

We have a Winforms app which is 10 years old, and has a huge codebase in the UI layer. 我们有一个10年前的Winforms应用程序,并且在UI层有一个巨大的代码库。 Writing unit test cases through NUnit or MS test would be a nightmare. 通过NUnit或MS测试编写单元测试用例将是一场噩梦。

So we have opted for UI automation rather than white box testing. 所以我们选择了UI自动化而不是白盒测试。

Now the difficult part is, we need code coverage info of source code. 现在困难的部分是,我们需要源代码的代码覆盖信息。

Is there any way through which I can get the source code executed/coverage of UI automation? 有什么方法可以让我获得源代码执行/ UI自动化覆盖?

Many thanks in advance. 提前谢谢了。

Visual Studio has a built-in code coverage measurement tools. Visual Studio具有内置的代码覆盖率测量工具。 There are 2 options. 有2个选项。

  • You may create so called "generic test(s)" that run(s) your test system with necessary params. 您可以创建所谓的“通用测试”,使用必要的参数运行您的测试系统。 In such a case you need to create a test project, to create a test run configuration and to do many other things through a "Test" menu (VS 2015 Professional contains such a menu, previous versions may require Test System or Enterprise). 在这种情况下,您需要创建一个测试项目,创建测试运行配置并通过“测试”菜单执行许多其他操作(VS 2015 Professional包含此类菜单,以前的版本可能需要测试系统或企业版)。

  • Another option is using the tools from command line as described in the MSDN docs . 另一种选择是使用命令行中的工具,如MSDN文档中所述

    • Use vsinstr -coverage <myassembly.exe> to instrument target binaries. 使用vsinstr -coverage <myassembly.exe>来检测目标二进制文件。
    • Use start vsperfmon -coverage -output: mytestrun.coverage to start collecting coverage data. 使用start vsperfmon -coverage -output: mytestrun.coverage开始收集覆盖数据。
    • After the tests are finished just open .coverage file in Visual Studio (coverage should be perfectly highlighted in the source code editor as well). 测试完成后,只需在Visual Studio中打开.coverage文件(覆盖率也应在源代码编辑器中完美突出显示)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM