Similar questions have been answered before, but they didn't solve my problem.
I am testing an api with create, read, update and delete methods. It is considered best to test each function separately. But,
To test create, I need to read. To test read, I need to create. To test update, I need to create and read. To test delete. I need to create!
I have no other (for example, lower layer api) mechanism of verifying other than this api itself.
In this case, should I write one long test with everything? Or 4 different tests; each with special setup and teardown logic.
Thanks
This is very subjective but I would write four different tests as it would
Readability
What would you name your testmethod if it tests everything? I find it easier to read testmethods in a form of CreateShouldCreateARecord instead of TestCRUD
Locate an error
With readability improved, it is easier to know what went wrong. Again, for one monolithic method, all you get in a report is that the TestCRUD method failed and you will have to drill down to find that it was a wrong implemented read.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With