C# Integration Testing Tutorial

Поделиться
HTML-код
  • Опубликовано: 25 окт 2024

Комментарии • 51

  • @lyubomyr6457
    @lyubomyr6457 Год назад +1

    I would suggest moving set-up stage to a constructor to avoid having initialization code inside every test. xUnit creates a new instance of test class for every test, so that tests won't share any state between each other, but it saves you from a lot of boilerplaiting.

  • @nataliasikorka4825
    @nataliasikorka4825 3 года назад +3

    Great tutorial as always! Thank you for your work ^^

  • @HarshaSuranjith
    @HarshaSuranjith Год назад

    Excatly what I was looking for, thanks for the great content.

  • @krs-tube
    @krs-tube 6 месяцев назад

    Thank you @RawCoding, what have you used as reference if anything at all, for the conceptual understanding of integration testing and then potentially for the implementation?

  • @loam
    @loam Год назад

    Also convinient option is to have database server running in docker container.

  • @sgroxatdgp
    @sgroxatdgp 10 месяцев назад

    I am testing something similar but I want to test a case with getting null data from my collection when there will be do data at the db collection. But as the tests running in parallel, my tests are overlapping and failing randomly. I have different class fixtures for these but all are accessing same db and collection. Is there any way to perform this without disabling the parallelisation ?

  • @sunnypatel1045
    @sunnypatel1045 3 года назад +3

    Brilliant job mate! I would like to make a small request. Could you do a video going through different collections like concurrent collection and async collections if that’s ok. Thanks

    • @RawCoding
      @RawCoding  3 года назад

      What do you mean collections? As in the tests them selfs?

    • @sunnypatel1045
      @sunnypatel1045 3 года назад +2

      @@RawCoding no not test just a video on different types of collections like the video you did with ienumerable

    • @RawCoding
      @RawCoding  3 года назад

      Aha is there specific thing that you are confused about or why do you think you need a tutorial about that?

    • @sunnypatel1045
      @sunnypatel1045 3 года назад

      @@RawCoding it be a good reminder recently I looked at concurrent collections and sometimes I get confused on what each one does.

  • @damientech88
    @damientech88 3 года назад +2

    Testing return values is easy. Testing a method which performs a whole bunch of tasks is where this falls over.

    • @RawCoding
      @RawCoding  3 года назад +2

      Well you’ve pretty much resolved the problem in the 2nd sentence with the 1st

    • @damientech88
      @damientech88 3 года назад +3

      @@RawCoding Most things in the real world are not basic CRUD or return a nice value wrapped in a bow. At some point, all of your units need to be strung together to perform a complex task and that rarely can be tested by returning a simple value.

    • @RawCoding
      @RawCoding  3 года назад +1

      Clearly a mistake has been made if it’s not simple, but I’m aware that happens all the time, heck even I’ve lived through it countless times. Do check the next 2 videos where you can find more ‘complex’ examples, where I show how to test with identity mocking and I think it’s making sure emails gets sent to admins and managers.

  • @RoboChickenAnimation
    @RoboChickenAnimation 3 года назад +5

    can you do some videos on design patterns?

  • @coder185
    @coder185 2 года назад +1

    How do i test methods that require httprequest results after a login from external sources => afterwards the test method calls a production database to save records. Is this kind of method untestable? I can't make the database in memory because the code in submethod defines the connectionstring and so on... Can i write tests for production environment?

    • @RawCoding
      @RawCoding  2 года назад

      It’s hard to tell from that description. You can make methods virtual and have your mock override them and return dummy data

  • @rootsharp9946
    @rootsharp9946 2 года назад +1

    So it's a unit test structure with integration testing functions. Is that it?

  • @speakoutloud7293
    @speakoutloud7293 8 месяцев назад

    Dude, your email notifications are making me crazy! I am not able to find my own emails.

    • @RawCoding
      @RawCoding  8 месяцев назад

      Which emails?

    • @speakoutloud7293
      @speakoutloud7293 8 месяцев назад

      17:01
      23:19
      24:36
      24:45
      24:50
      And probably more :p
      @@RawCoding

  • @xieweiling7543
    @xieweiling7543 3 года назад

    It's an awesome tutorial, I am still not very clear, for example, how should we test an asp.net Core Web API? What can we mock?

    • @RawCoding
      @RawCoding  3 года назад +2

      It’s coming son don’t worry

    • @xieweiling7543
      @xieweiling7543 3 года назад

      @@RawCoding That's exciting, recently I am building an asp.net core web api, I know I should create the test for the controller, but I don't really know how. Appreciate!

    • @RawCoding
      @RawCoding  3 года назад +1

      We test the controller in this video, what kind of test do you have in mind?

    • @xieweiling7543
      @xieweiling7543 3 года назад

      @@RawCoding like those http endpoints

    • @RawCoding
      @RawCoding  3 года назад

      So you want to test via http call rather than calling a method?

  • @PavloKhomiak
    @PavloKhomiak Год назад

    add this code to CreateDatabase() and forget for existing db exception
    bool exists;
    var commandExists = @$"select exists(
    SELECT datname FROM pg_catalog.pg_database
    WHERE lower(datname) = lower('{db}'));";
    await using (var c = new NpgsqlCommand(commandExists, connection))
    {
    exists = (bool) await c.ExecuteScalarAsync();
    }
    if (exists) return;

  • @compman73
    @compman73 3 года назад +2

    Good job Thank you
    but fast-paced teaching could not help much as we need to pause the video too many times

    • @RawCoding
      @RawCoding  3 года назад

      Cheers, it’s a hard balance to strike

  • @clearlyunwell
    @clearlyunwell 3 года назад +1

    👍🏽

  • @bramburn
    @bramburn 2 года назад

    Found it