Why We ALL Use xUnit over NUnit or MSTest?

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 พ.ย. 2023
  • During my career, I used the 3 main .NET testing frameworks and in this video, I share with you why nowadays most of us use xUnit over NUnit or MSTest.
    💎 Be a Patreon to get the source code: / gsferreira
    🚨 KEY LINKS
    🤝 Support me on Patreon (and get access to source code) here: / gsferreira
    💌 Free Developer Insights: guiferreira.me/newsletter
    👋 HEY FRIEND
    If you're new to my Channel, my name is Guilherme, but you can call me Gui if Portuguese pronunciation is not your thing.
    I see myself as a Minimalist Software Craftsman. That says a lot of what I talk about here.
    So, why this TH-cam channel? To share with you to simplify your life as a Developer through knowledge, technology, and practices.
    If you are into those things as I do, don't forget to subscribe for new videos.
    🔗 GET IN TOUCH
    LinkedIn: / gferreira
    Twitter: / gsferreira
    GitHub: github.com/gsferreira
    Get my newsletters: guiferreira.me/newsletter
    Visit my blog: gsferreira.com
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 35

  • @nibi2240
    @nibi2240 หลายเดือนก่อน +1

    Thanks a lot for this video! While I was learning Automation, the mentor didn't know to explain further the reason of (kinda nonsense) of acting by Nunit and since I watched ur video now everything is clear, and I can confirm that xunit is better

    • @gui.ferreira
      @gui.ferreira  หลายเดือนก่อน

      Great to hear! 😄

  • @GigAHerZ64
    @GigAHerZ64 6 หลายเดือนก่อน +2

    Couple years ago we compared NUnit and xUnit. We chose NUnit, because of parameterized arguments. If you have 2 arguments marked with [Range(0, 2)] attribute, it will combine all possible values and you will get 9 testcases out of 2 arguments with 3 possible values for each. (0, 1, 2) That's something we were unable to reproduce in xUnit.

    • @KoenHeye
      @KoenHeye 4 หลายเดือนก่อน +2

      I think it could be possible when you make use of xUnit with ClassData. You have to create a separate class and add elements to a collection. But the class itself is also reusable for multiple tests.

  • @BeanCoffeeBean
    @BeanCoffeeBean 7 หลายเดือนก่อน +6

    5:41 what king of stuff does MSTest under the hood for that speed difference o.o

  • @aj0413_
    @aj0413_ 6 หลายเดือนก่อน +2

    Oh hey, needed this, man. Went from writing tests all the time at last position using MSTest V2 to no tests at new company, but new team decided to finally push for unit testing in 2024. I wanted to re-evaluate which testing framework we should use before I gave my pitch and was struggling to recall why people may prefer one over the other

    • @gui.ferreira
      @gui.ferreira  6 หลายเดือนก่อน

      Glad you find it useful.
      If you have experience with MSTest, trust me, you will love xUnit 😉

  • @platzida01
    @platzida01 3 หลายเดือนก่อน +1

    Thanks a lot for this video . Very helpfull

    • @gui.ferreira
      @gui.ferreira  3 หลายเดือนก่อน

      Glad it was helpful!

  • @Tamer_Ali
    @Tamer_Ali 7 หลายเดือนก่อน +1

    thanks Gui, you awesome 👍

    • @gui.ferreira
      @gui.ferreira  7 หลายเดือนก่อน

      Thank you for watching🙏

  • @Rick104547
    @Rick104547 หลายเดือนก่อน

    I used to prefer xunit but lately I have switched over to nunit. The main reason being that nunit support assembly level fixtures (handy to spin up dependencies like a docker container) and has better parallelization (xunit runs tests in the same class and also collection fixture sequentially). This is a deal breaker if you do any serious integration tests. Since I also don't see much value in using both I just stick with Nunit everywhere.

    • @gui.ferreira
      @gui.ferreira  หลายเดือนก่อน +1

      Assembly level fixtures seems interesting. Thank you!

  • @tiagosutter8821
    @tiagosutter8821 2 หลายเดือนก่อน +1

    Thanks. Quick question, do you have experience with Playwright testing framework on C#, if so, would you recommend a setup for it using xUnit? From the docs it seems like NUnit is the preferred approach and its officially supported, but i've also seen some people using it with xUnit.

    • @gui.ferreira
      @gui.ferreira  2 หลายเดือนก่อน

      Hey! I would definitively fall back into NUnit for Playwright.
      This is why: github.com/xunit/xunit/issues/2003
      You can use xUnit with Playwright and you can be successful with it. However, I can foresee challenges down the road.

  • @alexandermackintosh1755
    @alexandermackintosh1755 4 หลายเดือนก่อน +1

    The only thing that still is very annoying is not being able to name each test case out of the box in xUnit with Theory. Otherwise I'm sold!

    • @gui.ferreira
      @gui.ferreira  4 หลายเดือนก่อน

      Interesting idea

  • @DhiegoMartinsAndrade
    @DhiegoMartinsAndrade 7 หลายเดือนก่อน +3

    How about Playwright support for xunit?
    Playwright is an important library for e2e testing and as far as I know it supports MSTest and NUnit, but not xunit.
    What are your opinions about it?

    • @gui.ferreira
      @gui.ferreira  7 หลายเดือนก่อน +1

      Thanks for bringing that up Dhiego.
      I confess I don't have experience with Playwright.
      I would definitively fall back into NUnit for Playwright.
      For those who are interested in why, here it is: github.com/xunit/xunit/issues/2003
      Thanks once again!

    • @michaeldimoudis
      @michaeldimoudis 7 หลายเดือนก่อน +2

      We use playwright for E2E tests with xunit without issue. Not sure we their docs are confusing by not listing xunit. Maybe because you don’t require anything, just the Microsoft.Playwright nuget package.

    • @gui.ferreira
      @gui.ferreira  7 หลายเดือนก่อน +1

      ​@@michaeldimoudis It might be a specific scenario where concurrent tests create a problem.
      I'm not sure, but maybe if you run your tests inside a Collection Fixture, it might reduce the chance of being a problem. I would have to try to confirm.

    • @michaeldimoudis
      @michaeldimoudis 7 หลายเดือนก่อน

      I just checked our code. They all run concurrently using an IClassFixture, with headless false and xvfb-run command to make headless false work. We only have around 7 or so tests, mainly to E2E smoke test critical paths after deployment.

  • @sadafziya5636
    @sadafziya5636 3 หลายเดือนก่อน

    Thanks for your Video, xunit even better than mstest v3 ?
    for me , its still confusing to choose one of them which I dont have any problem with it in future

    • @gui.ferreira
      @gui.ferreira  3 หลายเดือนก่อน +1

      Hey!
      They are all fine. However, in doubt, I recommend xUnit. Mostly because it's widely adopted.
      My order of preference is xUnit, NUnit, MSTest

  • @7th_CAV_Trooper
    @7th_CAV_Trooper หลายเดือนก่อน

    Because XUnit was built by the developers of NUnit as a replacement for NUnit.

  • @Panure
    @Panure 2 หลายเดือนก่อน

    NUnit gang

  • @i2um1
    @i2um1 7 หลายเดือนก่อน +9

    NUnit >>>>> xUnit > ... > MSTest
    For you Hello World projects they have no difference. For instance, show me an async constructor in xUnit.
    Also, you don't know features of all test frameworks.

    • @petrmalecik5661
      @petrmalecik5661 7 หลายเดือนก่อน +5

      You mean implementation of IAsyncLifetime? Boom u have your async constructor...

    • @volan4ik.
      @volan4ik. 5 หลายเดือนก่อน

      Lmao you tried)

  • @amirhosseinahmadi3706
    @amirhosseinahmadi3706 3 หลายเดือนก่อน +2

    Absolute nonsense. In NUnit you can omit the `[SetUp]` method. Also, one key advantage of NUnit's setup method over xUnit's use of constructors is that your setup method can be async, whereas you can't have an async constructor. So, that's not a win for xUnit, quite the contrary.
    This video failed to make any real argument for why xUnit is supposedly superior to NUnit.

    • @gui.ferreira
      @gui.ferreira  2 หลายเดือนก่อน

      As far as I know, [SetUp] is the only way to execute a common set of instructions before each test method on NUnit. How do I do it without the attribute? Can you share? I would love to learn that.
      You are correct. xUnit uses the IAsyncLifetime interface to implement an async setup.
      As I mentioned at the end of the video, I don't consider xUnit superior to the others. The only argument I make to adopt xUnit instead of NUnit or MSTest is the fact that is widely adopted by the community. I attribute that to historical reasons and to the way xUnit was designed.