✅ Integration testing
I just watched this video, and instead of seeding his database he is using a
Faker
class which generates the data. How does this work?
Within he is using a CustomerRequest
is this basically his DTO object?
Before watching his video my approach in Integration Tests was:
Seed Database
Run Test
Clear DB
Seed DB
Run Test
...
I wanted to optimize it hence I watched his video about Respawn
but it doesn't seem like he is seeding at all with the Faker
?
How does he test get requests if there is no data inside DB?
https://www.youtube.com/watch?v=E4TeWBFzcCw
Screenshot below this was taken at 1:28 min into the videoNick Chapsas
YouTube
The BEST way to reset your database for testing in .NET
Check out my courses: https://dometrain.com
Become a Patreon and get source code access: https://www.patreon.com/nickchapsas
Hello everybody I'm Nick and in this video I will show you what I think is the best way to reset your database to a clean state, every time you run a test. This works great with integration testing but other forms of test...
12 Replies
he creates customer using his post request, then he makes get request and checks responses
in your example Faker will just create random content for CustomerRequest
Gotcha, but how does he rely on that, aren't test ran in a random order in XUnit?
Or does it follow the methods from top to bottom?
i dont really remember, but it doesnt matter cuz he is making post request inside of GetAllCustomer... method
and he showed that he resets db on after each test file passed
I see, okay gotcha
Thanks that explains it
Is the faker just a library then or a self written coass which provides mock data?
its libraby
you can use it if you are lazy and dont want to make dozens unique objects
Gotcha, thanks
under the hood its probably just stores hundreds of pieaces of data of every type (email, full names, cities...)
and lets you get that data with convenient api
Yeah I searched it, looks pretty cool but not needed for my current project, maybe in the future 😉
One more question
Is it considered the standard in integration testing to do a post first then test the get? Or is it also okay to seed first then do the get?
i think when you work with db operations its better to have every test case be isolated
cause it could be pretty messy when for example your post request tests are failing but get requests work as they should
Gotcha so you would also prefer the seeding approach?
yeah
Alright thanks man 😉
Appreciate your help!