Це відео не доступне.
Перепрошуємо.
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 UA-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
5:41 what king of stuff does MSTest under the hood for that speed difference o.o
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
Great to hear! 😄
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
Glad you find it useful.
If you have experience with MSTest, trust me, you will love xUnit 😉
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.
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.
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.
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.
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?
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!
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.
@@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.
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.
Thanks a lot for this video . Very helpfull
Glad it was helpful!
thanks Gui, you awesome 👍
Thank you for watching🙏
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.
Assembly level fixtures seems interesting. Thank you!
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
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
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!
Interesting idea
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.
You mean implementation of IAsyncLifetime? Boom u have your async constructor...
Lmao you tried)
Because XUnit was built by the developers of NUnit as a replacement for NUnit.
NUnit gang
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.
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.