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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Code Coverage not showing results when unit test cases are run in D365 FO

(0) ShareShare
ReportReport
Posted on by 45

Hi Folks,

I've a requirement for generating code coverage for my unit test cases in D365 FO. I am using VS enterprise edition to analyse code coverage results for my test case, but unfortunately code coverage results are blank.I can only see the test case getting passed or failed.

I have done the following things in my environment,

  • Imported the .runsettings file to include the package in which code coverage needs to be analysed, 
  • Loaded all the symbols using debugging option.
  • In test results folder , I can see the file but no code coverage information is available.

While debugging the selected test cases , i can see "binary was not built with debug information" for my package dll.

Looking for your suggestions on this.

Thanks in advance.

Code-coverage.png

I have the same question (0)
  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    Can you share your runsettings file? FO builds always produce symbols so there must be something else missing.

    That said, code coverage with X++ is tricky. Because of the way pre/post handlers work you typically end up with a bunch of not covered code. This problem was avoided with chain of command, luckily, and we've talked about changing the compiler to have pre/post handlers work similarly to chain of command to avoid this problem - but it's the type of change that is a bit risky to introduce so we haven't put this on our backlog at all yet.

  • SanjayChandrasekar Profile Picture
    45 on at

    Thanks for your prompt reply. Currently i am testing classes which don't have event handlers subscribed, but unfortunately code coverage is not working with those classes too. 

    Please find below is my settings file,

      
        
          
            
            
    
              
                
                        
                    MyPackage
                  
                
                
                30000
                true
                true
                true
                true
    
                
                  Network Service
                  Everyone
                
    
                
                  
                    ^System.Diagnostics.DebuggerHiddenAttribute$
                    ^System.Diagnostics.DebuggerNonUserCodeAttribute$
                    ^System.Runtime.CompilerServices.CompilerGeneratedAttribute$
                    ^System.CodeDom.Compiler.GeneratedCodeAttribute$
                    ^System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverageAttribute$
                  
                
    
              
    
            
          
        
    
      
    
    

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    Try change the modulepath value to .*MyPackage*.*

  • SanjayChandrasekar Profile Picture
    45 on at

    Tried changing the value to .*MyPackage*.*.

    Still no luck, I am getting this kind of result when I run the test cases,

    pastedimage1574496829982v1.png

  • Suggested answer
    Joris dG Profile Picture
    17,775 on at

    Did you make a typo in your post here, or do you have one too many .* at the end there?

  • SanjayChandrasekar Profile Picture
    45 on at

    I just used the same format that you have mentioned like .*MyPackage1.*

    Is there any issue with IDE say like we need to uninstall and reinstall it again.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
Martin Dráb Profile Picture

Martin Dráb 565 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 450 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans