The Fastest Way to Run Your Tests in .NET

preview_player
Показать описание


Hello, everybody, I'm Nick, and in this video I'll show you what's the fastest way to run your tests in .NET using xUnit.

Don't forget to comment, like and subscribe :)

Social Media:

#csharp #dotnet
Рекомендации по теме
Комментарии
Автор

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

adamdiament
Автор

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.

Greenthum
Автор

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.

bslushynskyi
Автор

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.

rogeriobarretto
Автор

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

MatiasElisbergSørensen
Автор

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

ralmslb
Автор

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

chrisjohnson
Автор

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

YungDeiza
Автор

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

IronDoctorChris
Автор

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?

Punkologist
Автор

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

isnotnull
Автор

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

pqners
Автор

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

ryanelfman
Автор

Alternatively you use the superior test framework NUnit.

It supports multiple parallelizable scope definitions with zero additional setup.

caybokotze