Viewing Code Coverage Results outside of Visual studio

后端 未结 6 1391
我寻月下人不归
我寻月下人不归 2021-02-01 18:54

I\'ve got some unit tests, and got some code coverage data. Now, I\'d like to be able to view that code coverage data outside of visual studio, say in a web browser. But, when I

6条回答
  •  星月不相逢
    2021-02-01 19:13

    You can use the tool NDepend and visualize code coverage results imported from NCover, dotCover or Visual Studio coverage. The tool can show code coverage vs. lines of code in a colored treemap. This feature is especially useful to browse at a glance which portion of code is well covered or not by tests.

    You can also write and apply continuously code rules written over LINQ queries (CQLinq) like:

    From now, all types added or refactored should be 100% covered by tests

    // From now, all types added or refactored should be 100% covered by tests
    warnif count > 0 from t in JustMyCode.Types where
    
      // Match methods new or modified since Baseline for Comparison...
      (t.WasAdded() || t.CodeWasChanged()) &&
    
      // ...that are not 100% covered by tests
      t.PercentageCoverage < 100
    
      let methodsCulprit = t.Methods.Where(m => m.PercentageCoverage < 100)
    
    select new { t, t.PercentageCoverage, methodsCulprit }
    

    ...or also:

    • Types that used to be 100% covered but not anymore
    • C.R.A.P method code metric
    • Complex methods partially covered by tests should be 100% covered

    The panel Search by Coverage can generate such Code Query over LINQ, and displays instantly the matched code elements:

    Search methods by coverage

    Also, the tool can build a HTML/javascript reports that will show code rules violated or code queries results.

提交回复
热议问题