6 ms·
Wait - people are doing real http calls in unit tests, over a network, and complaining about multiple asserts in the test code?
by lodovic 4y ago
Wait - people are doing real http calls in unit tests, over a network, and complaining about multiple asserts in the test code?
- mollerhoj 4y agoHopefully the responses are stored locally and replayed on subsequent runs.
- tinyspacewizard 4y agoStill a bit flaky. In an OOP language mocking is appropriate or in an FP language defunctionalization.
- mollerhoj 4y agoHeh yeah but it can be used to write tests that check your assumptions about a 3 party api. Granted, It'll only fail once the test are rerun without the cache, but it can still be a valuable technique. It can be valuable to have a testsuite that a) helps check assumptions when implementing the connection and b) helps locate what part of it later starts to behave unexpectedly.
- deleted 4y ago[deleted]
- chopin 4y agoWhere I work milestone and release builds cannot make http calls other than to our maven repo. It's meant to further reproducible builds but your tests can't do this as well. I fire up an in-memory database to make my tests self containing.
- batiste 4y agoI have met people that thinks HTTP calls are great! - "But it tests more things!" Well ok, but those are integration tests, not unit tests... It is unacceptable that a unit tests can fail because of external system...
- int_19h 4y agoIt's far better to have integration tests without unit tests than the other way around.
- flqn 4y agoIt's not unusual to spin up a local dev server in the same environment (or on the same machine, ie at localhost) as the tests. There's an argument to say these aren't "unit" tests but your definition of "unit" may vary.
- warrenmiller 4y agoThey can be mocked surely?
- drewcoo 4y agoIt's not nice to mock people "doing real http calls in unit tests," even if they deserve it.
- warrenmiller 4y agoOh dear
- nsoonhui 4y agoFor mocking, the parent comment means "swapping out the external calls with dummy calls", not "laughing at the developer"
- kevincox 4y agoI'm 98% sure that they understood that and it was a joke.
- BurningFrog 4y agoYou failed a humor unit test.
- ThunderSizzle 4y agoWoops, did you see the joke fly right past you?
- tester756 4y agodefine "real" yes, we perform "somewhat real tests" - tests start the app, fake db, and call HTTP APIs it's really decent