Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Resolved Unity Test Tools - please recommend code coverage tool for unit tests

Discussion in 'Testing & Automation' started by dvan, May 20, 2015.

  1. dvan

    dvan

    Joined:
    Aug 9, 2014
    Posts:
    4
    Can anyone recommend a good tool for measuring code coverage by unit tests with nUnit?

    The Unity Blog has a good post showing how they measure various aspects of code coverage (decision, condition, condition/decision, and function coverage) in their c/c++ framework (link). Something similar to that functionality in a C# project would be awesome.

    So far, I have found these tools that work with mono but am yet to try them:
     
    Last edited: May 20, 2015
  2. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    Did you manage to find anything that works ?
     
  3. Seltzer

    Seltzer

    Joined:
    Jan 21, 2015
    Posts:
    2
    I also came across monocov as a potential solution. I haven't found examples of anyone else doing it yet. However, I did find that monocov is included in Unity's fork of mono, though the repository looks to be a bit dated: https://github.com/Unity-Technologies/mono

    In any case, it seems to boil down to whether the versions match up, and how to go about running mono on a Unity editor test (at least that's my ideal use-case). It seems like a potential crapshoot. Does anyone here have more in-depth knowledge on how Unity runs mono?
     
  4. mle_samlabs

    mle_samlabs

    Joined:
    Jul 14, 2016
    Posts:
    2
    anyone managed to get code coverage in Unity yet?
     
  5. Seltzer

    Seltzer

    Joined:
    Jan 21, 2015
    Posts:
    2
    I haven't managed to get anything working yet. I'm going to try out the dotCover CLI in Wine next. Seems like a pretty big ordeal just for coverage, but it works on Windows, and I know that someone has successfully automated it for a Windows-based Unity CI server. I'll post my findings if I come across something more conclusive.
     
  6. Xanewok

    Xanewok

    Joined:
    Mar 28, 2017
    Posts:
    1
    Seltzer, any progress on that? :)
     
  7. kdragos

    kdragos

    Joined:
    Jun 25, 2016
    Posts:
    13
    Just wondering if anyone was able to find anything that works yet.
     
  8. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    If you're using Visual Studio, there's dotCover which is great. i used it in the past and it worked great. The only limitation is that you'd probably won't be able to run tests that are executed inside Unity since it is the test runner in VS that actually executes them, and not Unity.
     
  9. schifers

    schifers

    Joined:
    Jul 22, 2013
    Posts:
    1
    I look forward to have this feature inside Unity Test Tools.
     
  10. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    Unity test tools is deprecated as most of its functionality is already built into the engine.
     
  11. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    221
    We are working on a Code Coverage solution that will work in your projects. It will be released as a Unity Package. Once you add that to your project you will get a new entry in Preferences with some coverage options.



    Initially, we will report coverage using the OpenCover format, but support for more formats is planned to be added later.
     
  12. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,222
    We live in exciting times :)
     
    hippocoder likes this.
  13. N3uRo

    N3uRo

    Joined:
    Dec 10, 2011
    Posts:
    648
    Thank you so much, really. In my organization I am in charge of the code base of the whole team and even having many tests done, without code coverage I am not able to see if I leave certain paths uncovered.

    A couple of years ago I suggested in the forum to add it but they didn't listen to me.

    Original thread: https://forum.unity.com/threads/tes...de-tests-and-code-coverage-with-nunit.447941/
     
  14. Sharfan

    Sharfan

    Joined:
    Dec 20, 2018
    Posts:
    1
    Thats great news.

    @ElvisAlistar is there an estimated date/period that this package will be released?
     
    OleJuergensen likes this.
  15. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    221
    @Sharfan We're still assessing the readiness of this. We could be doing a Preview release of it sooner or we could wait and work on it more and get something more production-ready out later. What we don't want to do is ship a Preview version of it and then never get to polish it later. I ask for your patience while we're looking at it from all angles. I know this has been a long-awaited and much-requested feature and we're working towards bringing it to you.
     
  16. cbauman

    cbauman

    Joined:
    Aug 29, 2011
    Posts:
    16
    Nice! Looking forward to this.
     
  17. N3uRo

    N3uRo

    Joined:
    Dec 10, 2011
    Posts:
    648
    Please keep us updated on this thread on how things are going on.

    Thanks.