C# Integration Testing Tutorial

  Рет қаралды 37,077

Raw Coding

Raw Coding

Күн бұрын

Пікірлер: 51
@lyubomyr6457
@lyubomyr6457 Жыл бұрын
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 4 жыл бұрын
Great tutorial as always! Thank you for your work ^^
@RawCoding
@RawCoding 4 жыл бұрын
Cheers)
@HarshaSuranjith
@HarshaSuranjith Жыл бұрын
Excatly what I was looking for, thanks for the great content.
@krs-tube
@krs-tube 10 ай бұрын
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?
@sgroxatdgp
@sgroxatdgp Жыл бұрын
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 4 жыл бұрын
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 4 жыл бұрын
What do you mean collections? As in the tests them selfs?
@sunnypatel1045
@sunnypatel1045 4 жыл бұрын
@@RawCoding no not test just a video on different types of collections like the video you did with ienumerable
@RawCoding
@RawCoding 4 жыл бұрын
Aha is there specific thing that you are confused about or why do you think you need a tutorial about that?
@sunnypatel1045
@sunnypatel1045 4 жыл бұрын
@@RawCoding it be a good reminder recently I looked at concurrent collections and sometimes I get confused on what each one does.
@loam
@loam 2 жыл бұрын
Also convinient option is to have database server running in docker container.
@damientech88
@damientech88 3 жыл бұрын
Testing return values is easy. Testing a method which performs a whole bunch of tasks is where this falls over.
@RawCoding
@RawCoding 3 жыл бұрын
Well you’ve pretty much resolved the problem in the 2nd sentence with the 1st
@damientech88
@damientech88 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 жыл бұрын
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.
@rootsharp9946
@rootsharp9946 3 жыл бұрын
So it's a unit test structure with integration testing functions. Is that it?
@RawCoding
@RawCoding 3 жыл бұрын
Yes
@coder185
@coder185 2 жыл бұрын
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
@RoboChickenAnimation
@RoboChickenAnimation 4 жыл бұрын
can you do some videos on design patterns?
@RawCoding
@RawCoding 4 жыл бұрын
We shall
@RoboChickenAnimation
@RoboChickenAnimation 4 жыл бұрын
@@RawCoding oo and possibly SOLID. Thanks so much
@devjutsu
@devjutsu 4 жыл бұрын
Enough SOLID, roll GoF patterns on 🤪
@RoboChickenAnimation
@RoboChickenAnimation 4 жыл бұрын
@@devjutsu why not both?
@RawCoding
@RawCoding 4 жыл бұрын
Can do both )
@xieweiling7543
@xieweiling7543 4 жыл бұрын
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 4 жыл бұрын
It’s coming son don’t worry
@xieweiling7543
@xieweiling7543 4 жыл бұрын
@@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 4 жыл бұрын
We test the controller in this video, what kind of test do you have in mind?
@xieweiling7543
@xieweiling7543 4 жыл бұрын
@@RawCoding like those http endpoints
@RawCoding
@RawCoding 4 жыл бұрын
So you want to test via http call rather than calling a method?
@GZPlays_uno
@GZPlays_uno 11 ай бұрын
Dude, your email notifications are making me crazy! I am not able to find my own emails.
@RawCoding
@RawCoding 11 ай бұрын
Which emails?
@GZPlays_uno
@GZPlays_uno 11 ай бұрын
17:01 23:19 24:36 24:45 24:50 And probably more :p @@RawCoding
@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;
@clearlyunwell
@clearlyunwell 3 жыл бұрын
👍🏽
@RawCoding
@RawCoding 3 жыл бұрын
Cheers
@compman73
@compman73 3 жыл бұрын
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
@bramburn
@bramburn 2 жыл бұрын
Found it
It’s all not real
00:15
V.A. show / Магика
Рет қаралды 20 МЛН
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
When To Unit, E2E, And Integration Test
14:58
ThePrimeTime
Рет қаралды 107 М.
Abstraction Can Make Your Code Worse
5:13
CodeAesthetic
Рет қаралды 685 М.
the TRUTH about C++ (is it worth your time?)
3:17
Low Level
Рет қаралды 833 М.
xUnit or NUnit? Picking the Right Testing Library
10:00
Nick Chapsas
Рет қаралды 51 М.
THIS stops 90% of C# Developers Learning TDD
19:40
Gui Ferreira
Рет қаралды 15 М.
The Best Way To Write Parameterized Tests In .NET Using xUnit
12:29
Milan Jovanović
Рет қаралды 16 М.
Stop Writing So Many Tests
10:02
Web Dev Simplified
Рет қаралды 99 М.
Dependency Injection Is Now Complete In .NET 8!
9:49
Nick Chapsas
Рет қаралды 97 М.
C# Delegates & Lambdas Explained
32:43
Raw Coding
Рет қаралды 39 М.