Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Feature Request Changing the bundled NUnit version

Discussion in 'Testing & Automation' started by liortal, Mar 1, 2019.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,179
    Currently, Unity automatically references a built-in NUnit assembly from the Unity installation folder.
    I am not 100% sure which NUnit version is that, but is it going to be possible to drop whatever NUnit version i want so my tests can use that ?
     
  2. ElvisAlistar

    ElvisAlistar

    Unity Technologies

    Joined:
    Oct 2, 2013
    Posts:
    214
    We are currently moving the Test Runner functionality into a package. The built-in NUnit is going to be a separate package referenced by the Test Runner one. So, in theory, you should be able to swap that one with any other NUnit version, but in practice, things might not work as expected if you do that or might not works at all.

    The reason is that the NUnit version we use contains some modifications compared to the original:
    - it removes System.Web.dll
    - changes some internal NUnit APIs to public, so that we could make our own test runner to use instead of their default one (required for dealing with platforms like WebGL, where multithreading isn't supported)
    - NUnit did not respect equality overloading, so checking for null on UnityEngine.Object and other things like that were added
    - maybe other things I can't remember

    I think the version of NUnit we currently use is 2.6.4 and we want to update to at least NUnit 3
     
  3. N3uRo

    N3uRo

    Joined:
    Dec 10, 2011
    Posts:
    622
    The latest version is compatible with .NET Standard 2. I don't know if it still references System.Web in that assembly

    https://www.nuget.org/packages/NUnit/

    Also about your fork and modifications... Did you suggested a pull request at that time with that valid points so you could use the original assembly still? It will be better for everyone.
     
    Last edited: Mar 10, 2019
  4. superpig

    superpig

    Quis aedificabit ipsos aedificatores? Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,153
    @ElvisAlistar We currently ship Unit 3.5-ish.

    The biggest thing we changed in NUnit was restructuring the execution engine to make it possible to write tests as coroutines (i.e. support for the [UnityTest] attribute). I did look at whether there was a nice way to upstream this but couldn't come up with anything that I thought would be appealing to Charlie and the team. Maybe once it's all packaged up, it'll be easier to figure something out.
     
  5. N3uRo

    N3uRo

    Joined:
    Dec 10, 2011
    Posts:
    622
    @ElvisAlistar @superpig I see that in 2019.2 alpha Test Runner it's already a separate package.

    I have two questions:
    1. Have you considered updating NUnit to the latest version? Now that it is "separated from Unity" (a separate package) will it make it easier for you to update NUnit from time to time and be able to be close to the latest version?
    2. Will it ever be possible to test with async/await/Tasks? Please see: https://forum.unity.com/threads/async-await-in-unit-tests.671608/
     
  6. Warnecke

    Warnecke

    Unity Technologies

    Joined:
    Nov 28, 2017
    Posts:
    17
    Hey.
    Updating nunit is something that we would like to look into when we have the bandwidth for it. However it is currently unknown for us how feasible it will be to do so and how much will break when we upgrade it. We cannot promise anything yet, but it is on our radar.
     
  7. DrummerB

    DrummerB

    Joined:
    Dec 19, 2013
    Posts:
    20
    I would also like to express my support for a more recent version of NUnit. Particularly because of the Order attribute for fixtures (instead of just methods) that was introduced in NUnit 3.8. This would be useful to ensure that e.g. the tests defined in SmokeTests are run first. Would also be nice to be able to toggle between different sort modes in the test runner (e.g. by Name, by Order)
     
    liortal and Stormy102 like this.