Testing in .NET is About to Change

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • Until the 30th of September get 30% off any course on Dometrain with code BTS30: dometrain.com/...
    Subscribe to my weekly newsletter: nickchapsas.com
    Become a Patreon and get special perks: / nickchapsas
    Hello, everybody, I'm Nick, and in this video I will introduce you to a brand new testing library in .NET called TUnit. TUnit aims to be the new way of doing testing in .NET and I am very excited about its future.
    Give TUnit a star on GitHub: github.com/tho...
    Workshops: bit.ly/nickwor...
    Don't forget to comment, like and subscribe :)
    Social Media:
    Follow me on GitHub: github.com/Elf...
    Follow me on Twitter: / nickchapsas
    Connect on LinkedIn: / nick-chapsas
    Keep coding merch: keepcoding.shop
    #csharp #dotnet #codecop

КОМЕНТАРІ • 71

  • @JackTheSpades
    @JackTheSpades Годину тому +57

    Personally I prefer PUnit.
    Testing in Production :3

  • @sergeybenzenko6629
    @sergeybenzenko6629 2 години тому +21

    We have shitty tests that randomly fail and depend on one another. Now we got a perfect framework to hide it and not having to fix these damn tests. YAY!!!

  • @markovcd
    @markovcd 2 години тому +18

    Now I can over-engineer my tests easier than ever! ;)

  • @dahahaka
    @dahahaka 3 години тому +22

    I use GUnit

    • @timur2887
      @timur2887 2 години тому +1

      TestsSucksUnit =)

  • @softwaretechnologyengineering
    @softwaretechnologyengineering 3 години тому +10

    Before assembly, what a fantastic way to hide weird behaviour in a large test suite.

    • @cyril113
      @cyril113 2 години тому

      Because doing things before tests is weird. And how is it going to hide it if the code that runs is annotated with Before(Assembly)?

    • @ShaezoNai
      @ShaezoNai Годину тому

      ​@@cyril113 ​
      Doing things before tests is fine. Doing things before EVERY test invites problems through dependencies and bloat, because a lot of people do not really understand what *should* be running before all tests. Then someone starts doing it, and some other person needs another thing for their tests and extends what is already there, and then it slowly, over weeks and months, grows into a tangled mess that is hard to maintain.
      Honestly, from my experience, a lot of people already struggle to figure out how to use a [Before(Test)] properly, let alone [Before(Class)]. This is just one step further up.
      "And how is it going to hide it if the code that runs is annotated with Before(Assembly)?"
      Because the code with this annotation is very likely not declared in the same class file that I am working on when my test fails. Yes, I can go and look for it, or maybe the test output log even tells me about it (I hope it does), but if I don't know it is there, I risk to end up in a scenario where my test fails with seemingly unexplainable behavior.
      This doesn't mean you should never have a [Before(Assembly)], it just means you have to be very careful and understand what you are doing.

    • @nickchapsas
      @nickchapsas  Годину тому +1

      Not true for acceptance tests where you’re spinning up a bit suite of tests.

  • @PeteRobinson-gb7nz
    @PeteRobinson-gb7nz 2 години тому +7

    We need *test* frameworks not just *unit* test frameworks (we use them for more than just unit tests)

  • @Cristian-ek7xy
    @Cristian-ek7xy 3 години тому +21

    I'm happy with NUnit

    • @Maloooon
      @Maloooon 2 години тому +2

      Yeah, I expected something really flashy. But aside from using the new test runner, it mostly feels like NUnit. Maybe it has a few more options for "Before", but otherwise, it feels the same.

    • @Domse65
      @Domse65 2 години тому +2

      xunit is streets a head of nunit

  • @MatinDevs
    @MatinDevs 3 години тому +20

    2:15 I love how nick chooses "random" numbers

    • @local9
      @local9 Годину тому

      If only the test ran for 260 seconds too

  • @BetrayedEnemy
    @BetrayedEnemy Годину тому +1

    Liked for "Assert DOT THAT DOT IS DOT " -Dance

  • @DotNetCookbook
    @DotNetCookbook Годину тому +2

    Really, most projects just need some library that can assert things and some framework that can run those assertions. I've never met a real-life scenario where unit-tests related reflection would be the bottleneck why unit tests run slowly.
    Also these days you might want to use a library that LLMs know about, so that you could autogenerate test cases sometimes. But that's about it, it's not that complicated.

  • @ryanelfman3520
    @ryanelfman3520 Годину тому +1

    So much hate in these comments. If you’ve never ran into the limitations of xUnit then you wouldn’t realize the benefits. A lot of people override the standard xUnit framework because parallelization in xUnit is bad and not as configurable as it should be. Once you do that it’s extremely difficult to use spec flow on top of it or some other framework
    This is excellent to see its source generated. It’s the way to go

  • @DoorThief
    @DoorThief 33 хвилини тому

    This is pretty cool. If I'm writing unit tests, its true I might not see the value with this framework if all my tests are perfectly isolated. But for integration tests/UI tests, i can finally not have it run in one giant method and finally have test order control! This is really useful for different types of testing.

  • @ArnonDanon
    @ArnonDanon 45 хвилин тому

    Thanks for intreducing a new tool to our toolbelt, now we know it exists we can decide if and when it might solve us a problem. Cool library thanks.

  • @BrianBehm
    @BrianBehm Годину тому +4

    What about support for build pipelines? Are there any pros and cons there?

  • @tridy7893
    @tridy7893 2 години тому +10

    There is no AI in it? Pfffff, what a waste. [ɯsɐɔɹɐs].

  • @rngesus8057
    @rngesus8057 2 години тому +2

    reminds me of the spec flow library

  •  Годину тому +1

    Thanks for the info. As always, refactor all unit tests and use it in production even if it's in preview library, you will thank me later.

  • @anth9623
    @anth9623 Годину тому +2

    Hmmm maybe overtime it will show more advantages over other testing frameworks, but NUnit/XUnit are both decent, well supported, and feature rich, so it does make it more difficult to switch at the moment. But that being said, it's new and no doubt will get better, so who knows 😊

  • @richie7425
    @richie7425 Годину тому +2

    I see no value bar its a bit faster. change for the sake of change. in the end you should be running the test your working for then a final full run before you push. after that the pipeline does the testing and really who cares on the speed of that since if its spec'd correctly it will be no issue. If my app is so large and complex that it is way to slow on testing. either your writing tests wrong or your at the point to rearchitecture and or move to go or something that better suits larger projects.

  • @loganbussell4855
    @loganbussell4855 11 хвилин тому

    Looks exciting, but I was hoping to see property-based unit testing here. Patiently waiting for the first library that makes it really accessible for .NET.

  • @Domse65
    @Domse65 2 години тому +1

    I see the same problem with TUnit and NUnit, which is not present with XUnit, which is thats it's a lot easier to use and code tests quickly with resharper. With just base resharper if I decide some line in my code needs to be setup before the test just a quick keyboard shortcut and its automatically moved to the constructor. This make writing tests a lot faster and easier since you don't need to write boilerplate code by hand.
    Also XUnit assert syntax is a lot better in my opinion

    • @nickchapsas
      @nickchapsas  Годину тому

      You can do the same thing in TUnit

  • @kinsondigital
    @kinsondigital 2 години тому

    Oh hell yes! I likey!!
    Yeah, this should get some funding sent it's way for sure.

  • @PaulSebastianM
    @PaulSebastianM 2 години тому +2

    I wish .Net had testing builtin like Rust and actually support the same way of having a testing module in the same file that is only compiled when running tests.

  • @olivier0003
    @olivier0003 2 години тому

    100k, you deserve it !

  • @goodfight1749
    @goodfight1749 3 години тому +9

    Man.. just used NUnit 😢

    • @fusedqyou
      @fusedqyou 3 години тому +7

      Keep using it. TUnit will not exceed NUnit in a long time, and any experience you gain will be usable in TUnit just as much.

    • @nickchapsas
      @nickchapsas  Годину тому +1

      Keep using it, TUnit is not ready yet

    • @juniorceccon
      @juniorceccon Годину тому +1

      It is ok to not be using every new thing all the time.

  • @tonygeorgiew7612
    @tonygeorgiew7612 2 години тому +1

    What is the point of DependsOnI(OtherTest) ? This is violation of FIRST principles in unit testing. Unit tests shouldn't depend on one another.

    • @nickchapsas
      @nickchapsas  Годину тому

      Like I said, it’s not for unit testing

  • @fakhrulhilal
    @fakhrulhilal 51 хвилина тому

    Nice, it's closer to NUnit rather than XUnit. I like they put `Before(Test)` which is feature I miss from NUnit but not in XUnit. But, I have to await for assertion? Ok, time to get used to.

  • @Zullfix
    @Zullfix 2 години тому

    Nick, would you consider making a video about required CET in .NET 9 and the 10-100% method calling performance regressions that come with it on any CPU that isn't a modern intel processor?

    • @nickchapsas
      @nickchapsas  Годину тому

      Wait that’s a thing??

    • @Zullfix
      @Zullfix Годину тому

      ​@@nickchapsas Yes, and it's causing major performance regressions for CPUs that do not have specialized hardware for CET. It also causes issues when interoping with other runtimes that don't support it, such as Java (the specific JVM is not named).
      UA-cam keeps removing my comments, probably because of my sources. You can check 107651 and 103654 in the dotnet runtime and 36619 in perf-autofiling-issues.

  • @modernkennnern
    @modernkennnern 46 хвилин тому

    Source generated test library 👀

  • @parlor3115
    @parlor3115 Годину тому +1

    Nah, this is just a conspiracy to cover the entire alphabet

    • @nickchapsas
      @nickchapsas  Годину тому

      I wished for G Unit but I wasn’t lucky this time

  • @regestea
    @regestea 2 години тому

    I think it's better to add these futures to XUnit or NUnit instead of recreating a library or maybe a package for XUnit or NUnit to add these futures because most of us don't like to go for a new library

  • @ahmedabd-a6
    @ahmedabd-a6 3 години тому

    Was it necessary to mention how handsome is he!! 😅😅.
    Great library will give it a try

  • @user-ko2yo3zx8h
    @user-ko2yo3zx8h Годину тому

    Add(6,9) nice 🤣

  • @SuperGulamali
    @SuperGulamali 35 хвилин тому

    Even if i wanted to use it, Projects will still just have N/X Unit 😂

  • @SnazzieTV
    @SnazzieTV 44 хвилини тому +1

    can we stop add more ways to write tests. Focus on doing less and less tests. Let AI write tests for us.

  • @BlTemplar
    @BlTemplar Годину тому +1

    The best way to write integration tests is not use C# to write them. I simply run my C# app and the environment in docker and send requests from jest tests in js. Tests are very short and run concurrently. Jest looks miles better than this.

    •  Годину тому

      Usually you want to test the final effects of the execution, such as if the data is correctly stored in the database. I'm not sure if this is easy with Jest but with standard integration tests you just query the same DB that was used for testing.

    • @Sergio_Loureiro
      @Sergio_Loureiro 7 хвилин тому

      There is no way Javascript ever could ever look better than c#.

    • @BlTemplar
      @BlTemplar 3 хвилини тому

      You can do queries in js of course but you don’t necessarily have to query the database manually. For example if you test POST endpoint you can check the result via GET endpoint

  • @local9
    @local9 Годину тому

    Why do I feel like I've used something like this in Java, christ I hate Java.

  • @MatinDevs
    @MatinDevs 3 години тому

    First!

  • @amirhosseinahmadi3706
    @amirhosseinahmadi3706 2 години тому +17

    Offers basically nothing interesting over xUnit/NUnit. I don't know what I'm supposed to be excited about here.

    • @nickchapsas
      @nickchapsas  Годину тому +9

      If you can’t see it then it’s not for you

    • @petropzqi
      @petropzqi 2 хвилини тому +1

      Same here. I can't see anything that I can't do in NUnit.