none
How to calculate coverage of .js and .cshtml file? RRS feed

  • Question

  • We would like to measure code coverage for JavaScript and .CSHTML files. These files are part of IIS hosted website. 

    We were able to measure code coverage of .DLL files by enabling them for instrumentation. Whereas for JavaScript and .CSHTML we are struggling. We are expecting  .JS and .CSHTML files to be enabled for code coverage and then run automated tests and finally generate coverage report. Currently we are struggling on how this can be done, please guide us.

    Your help will be highly appreciated!
    • Moved by Sabah ShariqMVP Monday, August 7, 2017 12:41 PM Moved From Visual C#
    Monday, August 7, 2017 3:33 AM

All replies

  • You may find some framework for unit testing JavaScript. UT-ing HTML is questionable. You can ask at the JavaScript and MVC sections at the ASP.NET forum.

    https://forums.asp.net/

    If you were using MVP instead of MVC, then you could easily UT the HTML controls, because you can use the Interface and address the objects on the form which I have done.

    https://www.infragistics.com/community/blogs/todd_snyder/archive/2007/10/17/mvc-or-mvp-pattern-whats-the-difference.aspx

    <copied>

    MVP Pattern
    • View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.
    • Easier to unit test because interaction with the view is through an interface
    • Usually view to presenter map one to one. Complex views may have multi presenters.

    <end>

     

    Monday, August 7, 2017 4:00 AM