Why We ALL Use xUnit over NUnit or MSTest?

  Рет қаралды 6,098

Gui Ferreira

Gui Ferreira

6 ай бұрын

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 KZbin 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

Пікірлер: 34
@nibi2240
@nibi2240 14 күн бұрын
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 8 күн бұрын
Great to hear! 😄
@BeanCoffeeBean
@BeanCoffeeBean 6 ай бұрын
5:41 what king of stuff does MSTest under the hood for that speed difference o.o
@GigAHerZ64
@GigAHerZ64 5 ай бұрын
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 3 ай бұрын
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.
@aj0413_
@aj0413_ 5 ай бұрын
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 5 ай бұрын
Glad you find it useful. If you have experience with MSTest, trust me, you will love xUnit 😉
@platzida01
@platzida01 Ай бұрын
Thanks a lot for this video . Very helpfull
@gui.ferreira
@gui.ferreira Ай бұрын
Glad it was helpful!
@Tamer_Ali
@Tamer_Ali 6 ай бұрын
thanks Gui, you awesome 👍
@gui.ferreira
@gui.ferreira 6 ай бұрын
Thank you for watching🙏
@tiagosutter8821
@tiagosutter8821 Ай бұрын
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 Ай бұрын
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.
@DhiegoMartinsAndrade
@DhiegoMartinsAndrade 6 ай бұрын
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 6 ай бұрын
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 6 ай бұрын
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 6 ай бұрын
​@@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 6 ай бұрын
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.
@alexandermackintosh1755
@alexandermackintosh1755 3 ай бұрын
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 3 ай бұрын
Interesting idea
@sadafziya5636
@sadafziya5636 Ай бұрын
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 Ай бұрын
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
@Rick104547
@Rick104547 15 күн бұрын
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 6 күн бұрын
Assembly level fixtures seems interesting. Thank you!
@Panure
@Panure 28 күн бұрын
NUnit gang
@I2um1
@I2um1 6 ай бұрын
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 6 ай бұрын
You mean implementation of IAsyncLifetime? Boom u have your async constructor...
@volan4ik.
@volan4ik. 4 ай бұрын
Lmao you tried)
@amirhosseinahmadi3706
@amirhosseinahmadi3706 Ай бұрын
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 Ай бұрын
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.
2024 .NET Software Testing Roadmap
7:51
Gui Ferreira
Рет қаралды 2,8 М.
THIS stops 90% of C# Developers Learning TDD
19:40
Gui Ferreira
Рет қаралды 12 М.
Normal vs Smokers !! 😱😱😱
00:12
Tibo InShape
Рет қаралды 120 МЛН
Eccentric clown jack #short #angel #clown
00:33
Super Beauty team
Рет қаралды 24 МЛН
Learn To Love DDD-Style Strongly Typed IDs
9:04
Zoran Horvat
Рет қаралды 22 М.
The BEST way to reset your database for testing in .NET
13:14
Nick Chapsas
Рет қаралды 59 М.
Unit Testing CQRS Handlers With Moq, Fluent Assertions, and xUnit
13:53
Milan Jovanović
Рет қаралды 32 М.
Do NOT Use Int IDs In Your API
8:01
Gui Ferreira
Рет қаралды 33 М.
The BEST Moq Alternatives: NSubstitute vs FakeItEasy
9:06
Gui Ferreira
Рет қаралды 3,6 М.
The cleanest way to use Docker for testing in .NET
13:36
Nick Chapsas
Рет қаралды 85 М.
What Are Your Thoughts on Entity Framework Core vs. Dapper?
21:49
Hexagonal Architecture (All You Need to Know)
9:51
Gui Ferreira
Рет қаралды 4 М.
How to Avoid Nulls
8:13
Gui Ferreira
Рет қаралды 2,3 М.
What is C#? What is the difference between C# and .NET?
6:33
Interview Happy
Рет қаралды 62 М.
Дени против умной колонки😁
0:40
Deni & Mani
Рет қаралды 9 МЛН
cool watercooled mobile phone radiator #tech #cooler #ytfeed
0:14
Stark Edition
Рет қаралды 7 МЛН
Will the battery emit smoke if it rotates rapidly?
0:11
Meaningful Cartoons 183
Рет қаралды 951 М.
Apple, как вас уделал Тюменский бренд CaseGuru? Конец удивил #caseguru #кейсгуру #наушники
0:54
CaseGuru / Наушники / Пылесосы / Смарт-часы /
Рет қаралды 4,5 МЛН