0

my application is built using aspx, aspx.cs, ascx and ascx.cs files. i want to do code coverage for all of these files. I don't have Unit tests existing. please let me know if I can do code coverage without any unit tests directly?? if yes, how?

Thanks in advance, Shweta

Shweta
  • 11
  • 1
  • -1, for not trying to search before asking. – Devendra D. Chavan Mar 09 '11 at 13:24
  • 2
    @Manish: link to a book of that title that actually solves the problem and you're giving a snide, helpful suggestion. Do what you did and you're just being snide without being helpful. – Joachim Sauer Mar 09 '11 at 13:46
  • Nope. Have been giving helpful suggestions since long. Every time. This was the time I felt it is useless. If you feel no, then look at the answer below. I edited it to make it more readable. – Manish Sinha Mar 09 '11 at 16:58
  • @Devendra: I have already searched a lot to get the answer for my question. from my search i got to know that there are different ways to do code coverage but all are with unit tests. I want code coverage without unit tests. @Manish and Dev: thanks for your answers. Like how we have code coverage tools for c and c++ which don't need unit test's existence (ex: bullseye code coverage tool using manual testing of application), I wanted to know if there are any tools for c# which provide flexibility to do code coverage directly with code without unit tests or just with manual testing. – Shweta Mar 10 '11 at 04:03
  • @Shweta, the code coverage method that is done via manual testing is not very reliable. Unit tests are required as a measure of code coverage of your code (it is more like an automated testing). There is no guarantee that all the business logic will be triggered when manual testing for code coverage has been done. Unit testing is a lot simpler and is particularly useful in test driven development. Are you sure that you want to go ahead with code coverage with manual testing? – Devendra D. Chavan Mar 10 '11 at 08:01
  • @Shweta: When we say unit tests, it usually means automatic code coverage using unit tests. I personally feel that writing Unit tests would be a better solution as in future when you add a bunch of functionality,you can run those tests again to determine the code coverage. This approach is more helpful in long run. Manual-testing-code-coverage will keep on becoming tougher as days pass and the codebase increases. – Manish Sinha Mar 10 '11 at 08:02
  • @Shweta: I would recommend following the good practices. If you write unit tests, then anyone who takes your codebase can check if the functionality they added breaks the existing codebase or not. Additionally the person who takes your code is also relieved of doing the testing himself manually. With C# writing unit tests is very easy. Very easy. Just look at NUnit (which I use and find it very useful and simple) – Manish Sinha Mar 10 '11 at 08:05
  • Similar question: [Code coverage for people (manual) tests?](http://stackoverflow.com/questions/723844/code-coverage-for-people-manual-tests) – Devendra D. Chavan Mar 10 '11 at 08:08

1 Answers1

0

I don't think you can get code coverage with out unit tests -

Code coverage is a measure used in software testing. It describes the degree to which the source code of a program has been tested.

It is a form of testing that inspects the code directly and is therefore a form of white box testing.

In time, the use of code coverage has been extended to the field of digital hardware, the contemporary design methodology of which relies on hardware description languages (HDLs).

Manish Sinha
  • 2,092
  • 2
  • 22
  • 33
Anuraj
  • 18,859
  • 7
  • 53
  • 79
  • On a related note, consider migrating away from web forms if you want unit testing and code coverage to be a vital part of your application. ASP.NET MVC gives you some amazing control over your code and is completely unit testable. – CatDadCode Mar 09 '11 at 18:42