Search Unity

Is it possible to replace NUnit with xUnit?

Discussion in 'Testing & Automation' started by Garzec, Jul 18, 2021.

  1. Garzec

    Garzec

    Joined:
    Mar 3, 2016
    Posts:
    151
    When creating unit tests Unity makes use of the NUnit test framework



    Is there a simple way to replace NUnit with xUnit?

    So all the features provided by Unit behave the same as before but I can write the tests with xUnit :)
     
  2. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    No, there's no simple way to do this. The com.unity.test-framework package is deeply integrated with NUnit.
     
  3. Garzec

    Garzec

    Joined:
    Mar 3, 2016
    Posts:
    151
    hmm :( Ok

    Any chances it will change in the future?
     
  4. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    Never say never, but we have no plans to add support for other test frameworks at this time, sorry.

    Is there something in particular you need from it?
     
  5. Garzec

    Garzec

    Joined:
    Mar 3, 2016
    Posts:
    151
    No, nothing special.

    I personally prefer xUnit, but that's my personal opinion :)

    I think it's easier to write tests, e.g. instead of using the [Setup] annotation for a Setup method you can simply use the constructor.
     
  6. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    Right. Yeah, sorry, we are not going to rewrite the whole test package just for reasons of personal preference :)

    One interesting note about your specific example: that would actually make it impossible to implement [UnitySetUp] on top of xUnit, because you can't have a constructor which is an iterator block.
     
  7. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,051
    What about updating NUnit version @superpig? it's a recurring request.
     
  8. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,657
    Yes, that one is on our roadmap. No ETA yet though, sorry.
     
    ForNoOne and bdovaz like this.
  9. io-games

    io-games

    Joined:
    Jun 2, 2016
    Posts:
    104
    It seems some reporting tools (allure, gitlab ci) do not understand nunit xml. Need to convert to junit.