Skip to main content

How to use Code Coverage effectively: Part 1/2

:: Optimizing Code Coverage Page ::

   As a Dynamics NAV developer, we all are familiar with this veteran tool for code tracking, The Code Coverage. This tool is very different from debugging as we don’t halt the transaction or process with breakpoints. It simply track all the codes executed during its capturing process from start to stop. It tracks all the code lines and count the line hit during the execution.

   In Dynamics NAV previous versions like 2009 SP1 & 2009 R2 it was a great tool for developers to fix calculation issues which doesn't cause runtime error, Third party tool integrations or Tracking codes for developing new functionality in a module.

   It feels gloomy to realize how this tool has lost its usability in recent versions. Recently I encountered G/L CONSISTENCY error in a transaction which is nothing but a calculation traggic in one of G/L entry. I tried debugger but unfortunately it didn’t work for me. Then I recalled, our this old friend but when it introduced to its new GUI, I was completely shattered. . ..

Code Coverage Standard Page

This new Code Coverage UI as page object doesn't help users much, code readability is pathetic as the code lines hit are not highlighted. I tried Export to XML in hope of some miracle but this too is 😕 never mind. Print & Send to Microsoft Excel failed to export more than 5000 lines. As Code Coverage shows all the functions and its code lines from an object regardless it is hit or not and causes increased numbers of code coverage lines, which is hard to track. 

This blog includes information on this issue and how I customized/optimised it to make it work and accomplish my task. I hope if you are trying to use Code Coverage in recent NAV versions this might help you.

After few code tweaking, I transformed Code Coverage page to look as below. 😂 Ya'ay!!!

Code Covergae Modified Page



To achieve this I added the following simple to code in Page 9990 under SetStyles function.
Code Coverage Page SetStyles Function


Now the Code Coverage page is more convenient for code readability but our job is not done yet. .  ..

Up Next on Part 2 >> 

1. Fixing Export to Excel.

2. Comparing Coverage lines from multiple sessions. 

Comparing Coverage lines from multiple sessions preview

Comments

Post a Comment

Please let me know about your thought on this: