Code Coverage Using RDi
I was discussing code coverage recently with a contact of mine, so when I got back to my desk I thought I'd have a look at it and see what it was all about.
So I fired up RDi and found it here.
The first thing to do was configure what I wanted to test, so I clicked Compiled Code Coverage Configurations...you can actually see my configuration at option 1. but I'll show you how I got there.
Compiled Code Coverage Configurations
Here is the configuration I created for a program that features in my previous posts MITMCLAS - I have refactored this program from an AS/SET generated RPG III program - don't worry it's not that bad.
The next tab asks you how you are going to start this program when you run it interactively. As I've checked this program out and changed it in my development library I can specify it here.
The other relevant tab is Code Coverage and here you can specify the level of what you want to cover.
Testing your application
So that is as much as I did, now press the Compiled Code Coverage and off you go. You will need a IBM RSE Communications Server session going and I started mine in line on my application menu so I had my library list set correctly for my application I was testing. When you go to that session you will see your application running, hopefully!!
Here is mine - looks pretty basic - file maintenance sub file program
You can see the call to the program as defined earlier..
And here is the program running
So I run my tests....and now for the good bit..
When I end the program and go back to RDi here is what I see.
For each test I have a line telling me how much I have tested my program in that session. The status column indicates that I have not reached the 80% threshold indicated below.
Double clicking the second line gives you details of code actually executed in green. So you can page thru the code and see what you've missed in your tests. The subroutines in red mean that the code inside is not completely green - some of it may be.
And you can generate HTML and PDF reports..
Here is an example of the HTML page generated.
I did get a couple of crashes when I tried to export so I may look at updating my RDi to see if that stops it.
Susan Gartner has written a little about code coverage here.
But the most surprising thing for me was that my code and testing was on my old dev box running V6R1 - so don't be discouraged if you are using an older dev box.
If you have any questions or I can help you at all, please contact me thru the contact page or comment on LinkedIn.