The Fastest Way to Run Your Tests in .NET

The Fastest Way to Run Your Tests in .NET

Nick Chapsas

10 месяцев назад

30,367 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@user-fe5nv2ex3x
@user-fe5nv2ex3x - 19.10.2023 03:28

Thanks so much for sharing!

Ответить
@pavelprchal8625
@pavelprchal8625 - 18.10.2023 21:24

Finally, I ended up with own console app and reflection... NUnit can be frustrating,if you need to test appdomains

Ответить
@marines2002
@marines2002 - 18.10.2023 13:47

Hi Nick any idea how to use this with specflow and xunit get this error "Duplicate 'Xunit.TestFramework' attribute"

Ответить
@integrsolutions7064
@integrsolutions7064 - 17.10.2023 23:57

The fact is XUnit parallelization is on by default, but It is class-dependant as you showed, or feature-based in case of working with SpecFlow, it will treat each feature file as a collection, even with Meziantou

Ответить
@first-last-null
@first-last-null - 17.10.2023 12:38

You should show us Playwright for dotnet running in parallel with NUnit. I have an example repo called nullptrerror/DotNetE2EStarterKit that you can use as a starting point.

Ответить
@caybokotze
@caybokotze - 17.10.2023 10:46

Alternatively you use the superior test framework NUnit.

It supports multiple parallelizable scope definitions with zero additional setup.

Ответить
@CharlesBurnsPrime
@CharlesBurnsPrime - 17.10.2023 06:27

I think it's time for another Blazor video with the upcoming release of .NET 8. It appears to finally be a platform that we can take seriously as an alternative to React and friends.
Also, honest opinion, the videos that involved correcting LinkedIn posts are not particularly interesting, at least not to me.

Ответить
@DanielMitchellPunkologist
@DanielMitchellPunkologist - 17.10.2023 03:58

Hey Nick, I'm doing your unit testing course but I have a wierd problem in Visual Studio. It seems to double up all the tests in the test explorer and runs them all twice. Also the "double up" that I have skipped seems to ignore the Skip ="" and still runs the test (the first instance of the test works as expected), resulting in a failed test. I just can't figure out why it is doing this. Any ideas? have you seen this before?

Ответить
@ryanelfman3520
@ryanelfman3520 - 17.10.2023 01:35

Doesn’t work with IAssemblyFixture. Ended up needing to write custom xUnit runner

Ответить
@user-et4ch2xe4k
@user-et4ch2xe4k - 16.10.2023 21:05

Thanks a lot. I would like to see a video on the same subject, but with multiple test projects.

Ответить
@adamdiament3214
@adamdiament3214 - 16.10.2023 20:11

Looks good Nick thanks. You didn't really go into it but just hinted at the fact there would be ways to achieve parallelism and still benefiting from class/collection fixtures. It would be cool to see a "part 2" on that

Ответить
@Greenthum6
@Greenthum6 - 16.10.2023 19:30

I have always used NUnit where parallel execution is built-in. I haven't used xUnit much, but it is strange that you need to install external libraries to achieve this. However, xUnit probably gets the job done as well.

I write all tests to support parallel execution if applicable. This may work for unit tests easily, but for integration and UI tests it gets much more complicated.

Ответить
@IronDoctorChris
@IronDoctorChris - 16.10.2023 17:47

Seems like a pretty big downside vs NUnit which has very easy ways to manage parallelism

Ответить
@PanzerFaustFurious
@PanzerFaustFurious - 16.10.2023 17:37

Meziantou.Xunit

Ответить
@pqners
@pqners - 16.10.2023 17:18

First I read in the title: The fastest way to ruin your tests in .NET 😂

Ответить
@YungDeiza
@YungDeiza - 16.10.2023 16:56

Is it possible to set it up so that you have to enable parallelisation per class rather than disable it?

Ответить
@ralmslb
@ralmslb - 16.10.2023 15:40

Not a fan of "magical" solutions...
Would rather like to understand what is that Nuget package doing.

Ответить
@bslushynskyi
@bslushynskyi - 16.10.2023 15:35

Interesting fact that by default in one test class tests are executed sequentially, but the order of tests is not garanteed. Basically, order is random.

Ответить
@chrisjohnson7255
@chrisjohnson7255 - 16.10.2023 15:28

I solve the state issue by having an initialize method run that resets all state, I think I do it with the test initialize attribute in nunit so I’m sure their could be something similar in XUnit. I used to have tons of state issues and now I don’t, cheers

Ответить
@isnotnull
@isnotnull - 16.10.2023 14:51

I don't see how it can significantly increase the performance in real applications. If you have 100 test classes 5 methods each you will not have enough threads to execute all of the methods at the same time. So if a test runs every class testcase subsequently and in parallel you have other 99 classes which are go to thread pool to execute in parallel, the performance is going to be almost the same

Ответить
@rogeriobarretto
@rogeriobarretto - 16.10.2023 14:50

Really good to know that, learned new stuff!
We can only achieve this parallelization in the same collection using the Package? Wondering why xunit didn't added this be default.

Ответить