473,405 Members | 2,167 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

Writing a Coverage Tool for C#

tjm
Pure coverage from Rational is the only coverage tool I've been able
to find for C#, and I don't really want to pay what Rational charges
for something as simple as a coverage tool. So, I'd like to try to
write my own, but I'm having trouble getting started. The way I see
it, I need to do the following…

1) Create a debugger object or something similar that will allow me
to step through my code.

2) Start a process to run through my unit tests, and use the debugger
to determine which lines of code execute.

I've looked into the Debug and Debugger classes in the MSDN
documentation, but neither of them seem to offer the functionality I
need. Can anyone tell me how to step through code like the debugger
does so I can determine which lines of code are executed? Any help to
get moving in the right direction on this would be greatly
appreciated.
Nov 15 '05 #1
5 1230
Refleftion
"tjm" <tj***@rocketmail.com> wrote in message
news:a5**************************@posting.google.c om...
Pure coverage from Rational is the only coverage tool I've been able
to find for C#, and I don't really want to pay what Rational charges
for something as simple as a coverage tool. So, I'd like to try to
write my own, but I'm having trouble getting started. The way I see
it, I need to do the following.

1) Create a debugger object or something similar that will allow me
to step through my code.

2) Start a process to run through my unit tests, and use the debugger
to determine which lines of code execute.

I've looked into the Debug and Debugger classes in the MSDN
documentation, but neither of them seem to offer the functionality I
need. Can anyone tell me how to step through code like the debugger
does so I can determine which lines of code are executed? Any help to
get moving in the right direction on this would be greatly
appreciated.

Nov 15 '05 #2

"tjm" <tj***@rocketmail.com> wrote in message
news:a5**************************@posting.google.c om...
Pure coverage from Rational is the only coverage tool I've been able
to find for C#, and I don't really want to pay what Rational charges
for something as simple as a coverage tool. So, I'd like to try to
write my own, but I'm having trouble getting started. The way I see
it, I need to do the following.

1) Create a debugger object or something similar that will allow me
to step through my code.
Best as I can tell, this isn't possible directly in .NET. cordbg.exe appears
to import from imagehlp.dll for most of its features, you will have to
research how to write debuggers in general.
There is almost certainly no directly available class in the framework to
do this, it may be possible to import the functions(or write in MC++) to
achieve that goal, I don't know. When I have a bit more time I'll see what
else I can find out and I'd appreciate it if you post any further
information you find here.

2) Start a process to run through my unit tests, and use the debugger
to determine which lines of code execute.

I've looked into the Debug and Debugger classes in the MSDN
documentation, but neither of them seem to offer the functionality I
need. Can anyone tell me how to step through code like the debugger
does so I can determine which lines of code are executed? Any help to
get moving in the right direction on this would be greatly
appreciated.

Nov 15 '05 #3
Hi tjm,

"tjm" <tj***@rocketmail.com> wrote in message
news:a5**************************@posting.google.c om...
Pure coverage from Rational is the only coverage tool I've been able
to find for C#, and I don't really want to pay what Rational charges
for something as simple as a coverage tool.

<snip>

One possible way to do this would be to "hook" the C# compiler and
insert "logging" calls at the top and bottom of each method in the output
assembly. Such a technique is described here (but for a different purpose):

http://codeproject.com/dotnet/model_...nts_in_net.asp

As you'll see, it's decidedly non-trivial, which could explain why
Rational charges so much.

Regards,
Dan
Nov 15 '05 #4
Here's a better article (same technique, though):

"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
Hi tjm,

"tjm" <tj***@rocketmail.com> wrote in message
news:a5**************************@posting.google.c om...
Pure coverage from Rational is the only coverage tool I've been able
to find for C#, and I don't really want to pay what Rational charges
for something as simple as a coverage tool. <snip>

One possible way to do this would be to "hook" the C# compiler and
insert "logging" calls at the top and bottom of each method in the output
assembly. Such a technique is described here (but for a different

purpose):
http://codeproject.com/dotnet/model_...nts_in_net.asp

As you'll see, it's decidedly non-trivial, which could explain why
Rational charges so much.

Regards,
Dan

Nov 15 '05 #5
Darned itch trigger finger! Anyway...here's a better article (same
technique, though):
http://msdn.microsoft.com/msdnmag/is...f/default.aspx

"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:ub**************@TK2MSFTNGP09.phx.gbl...
Hi tjm,

"tjm" <tj***@rocketmail.com> wrote in message
news:a5**************************@posting.google.c om...
Pure coverage from Rational is the only coverage tool I've been able
to find for C#, and I don't really want to pay what Rational charges
for something as simple as a coverage tool. <snip>

One possible way to do this would be to "hook" the C# compiler and
insert "logging" calls at the top and bottom of each method in the output
assembly. Such a technique is described here (but for a different

purpose):
http://codeproject.com/dotnet/model_...nts_in_net.asp

As you'll see, it's decidedly non-trivial, which could explain why
Rational charges so much.

Regards,
Dan

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: John J. Lee | last post by:
Anybody know of one? Actually, I have a feeling that emacs understands a standard format for errors, which would make it really easy to implement this by having the coverage tool print results...
6
by: tjm | last post by:
Pure coverage from Rational is the only coverage tool I've been able to find for C#, and I don't really want to pay what Rational charges for something as simple as a coverage tool. So, I'd like...
4
by: O. Zimmermann | last post by:
Hello, I am looking for a tool to process torough UNIT and COVERAGE testing over 60 and more functions of a "critical" embedded application written in C. I found IPL's Cantata++ but we don't...
1
by: =?UTF-8?B?TWFydGluIFDDtnBwaW5n?= | last post by:
Hello, I am searching for a good profiling tool for C# which can be easily embedded into Visual Studio. My objective is to measure the times and counts of every method in my program. If...
7
by: Kai Zhu | last post by:
Can anybody show me a list of such tools so that I can pick up the tools match my requirement.
5
by: ev | last post by:
Hello, We are looking for any testing tool that is capable of checking code coverage for C,C ++ and Java code. Or at least for C and C++. We want to know how much (percentage) of our code written...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.