In Memory Databases | Unit Testing With C# and XUnit

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

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

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

    This is good information. In-Mem is appropriate to test Repositories. Which is 90%. Custom data methods are tested in integration tests. I agree.

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

      I think it is worth noting that In-Mem is also very good for teaching or demoing code.

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

    I think in-memory DBs are useful for testing Repositories and as you mentioned for integration with the DB we should use integrations tests, duh :D
    I really liked this video, but can you please also provide the source code?

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

      I never thought of providing the source code to be honest 😅
      I’ll make sure I provide a link to the source code in the description for future videos and will add it to this one as soon as I can!

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

    What was alternative to in memory database testing then?

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

      Since this video came out, Microsoft actually recommend against in memory databases for testing. Best thing to do is to mock out the repository when unit testing and use a docker image when you want to test the interaction with the database.
      Hope this helps

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

    So, a in-memory database will not be a problem, as long as it is just used to unit test, and not for integration test?

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

      You have to take into account that an in memory database won’t do anything more than put data there. It won’t check for relational integrity and doesn’t check database validation.
      So it all depends on what you’re test is doing. If you’re just using it to check simple logic then a in memory database is a nice option. If you’re writing tests that actual check the interaction with the database (integration tests, repository tests) then I would avoid in memory databases.