web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

How to get the code coverage in x++

(0) ShareShare
ReportReport
Posted on by 512

Hi Guys,

I have a problem in how to get the code coverage in x++. I try to follow the link below regarding the coverage.runsettings.

https://daxmusings.codecrib.com/2019/02/repost-enabling-x-code-coverage-in.html

But it seems there is no hit objects for the code coverage.

2110.pastedimage1597907158186v2.png

Thank you for your response.

Regards, 

CJ

I have the same question (0)
  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi CJ,

    Have you tried Test framework.

    Please refer to this link - docs.microsoft.com/.../testing-validation

  • CJ Profile Picture
    512 on at

    Hi Gunjan,

    Thank you so much for your answer. I have already read this article but this is regarding the unit testing. I have already created the unit testing and perfectly pass but when I run the analyze code coverage it will not hit those objects. The results always 0 code coverage.

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Hi CJ,

    Looks like you are trying to do a code coverage for methods in a form data source extension. Are you importing a task recorder for the same?

  • Martin Dráb Profile Picture
    239,632 Most Valuable Professional on at

    He's running a unit test, which doesn't involve Task Recorder. You write a unit test method and execute it from Test Explorer.

  • Gunjan Bhattachayya Profile Picture
    35,429 on at

    Martin,

    I have seen and used unit test cases for tables and classes, creating and deleting dummy data, I am not sure how it is used for form code.

    I was going through the link and saw that we can create a test module to manage form adapters. Is there any way we can use the unit tests to test form datasource methods?

  • Verified answer
    Martin Dráb Profile Picture
    239,632 Most Valuable Professional on at

    Form adapters were deprecated a few years ago. You can find examples of code in the blog post where Microsoft announced the replacement: type providers.

    Nevertheless he said he's able to run the test. The problem is code coverage.

  • pjcobas Profile Picture
    on at

    Has anyone found a solution to this problem?

    I have the exact same issue, unit tests run , but code coverage returns empty results generated.

    Thanks.

  • Sagar Kamble Profile Picture
    32 on at

    I am getting code coverage in VS 2019. I have performed the following steps

    • Create a new .runsettings file in your environment. (Create a notepad file and rename the extension to . runsettings)
    • Got to https://docs.microsoft.com/en-us/visualstudio/test/customizing-code-coverage-analysis?view=vs-2019.
    • from above link, copy the code from “Sample .runsettings file” section.
    • Paste the code in .runsettings file.
    • Goto, <ModulePaths> section
    • In <Include> section, Add your model name in module path. Suppose your model name is “ABC model”. Add the module name below

                  <ModulePath>.*ABCModel.*</ModulePath>

               Module path section will look like as below

               <ModulePaths>

                  <Include>

                                 <ModulePath>.*ABCModel.*</ModulePath>

                  </Include>

              </ModulePaths>

    • Save the file.
    • Goto VS ,goto Test -> Configure Run Settings ->Select solution wide runsettings file.
    • Select the newly created runsettings file.
    • Run Analyze code coverage for all test cases.   

    Hope this will help

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 804

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 639 Super User 2026 Season 1

#3
Subra Profile Picture

Subra 528

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans