3

We have a Winforms app which is 10 years old, and has a huge codebase in the UI layer. Writing unit test cases through NUnit or MS test would be a nightmare.

So we have opted for UI automation rather than white box testing.

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?

Many thanks in advance.

jalopaba
  • 8,039
  • 2
  • 44
  • 57
Rudrappa
  • 31
  • 1

1 Answers1

1

Visual Studio has a built-in code coverage measurement tools. There are 2 options.

  • 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).

  • Another option is using the tools from command line as described in the MSDN docs.

    • Use vsinstr -coverage <myassembly.exe> to instrument target binaries.
    • Use start vsperfmon -coverage -output: mytestrun.coverage to start collecting coverage data.
    • After the tests are finished just open .coverage file in Visual Studio (coverage should be perfectly highlighted in the source code editor as well).
Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
  • Thanks worked, but did not get how to analyse the code Coverage File generated as output. Its looks like encoded file. Any editor/approach if know to analyse it? – Rudrappa Mar 02 '16 at 14:46
  • Did you try opening it as a file while your solution is open? – Vasily Ryabov Mar 02 '16 at 17:30