Re:Stop requiring only one assertion per unit test: Multiple...
by lodovic on Saturday November 05, 2022 @06:13AM
(#33479911)
Wait - people are doing real http calls in unit tests, over a network, and complaining about multiple asserts in the test code?
[ Parent
| on HN ]
Re:Stop requiring only one assertion per unit test: Multiple...
by mollerhoj on Saturday November 05, 2022 @06:40AM
(#33480114)
Hopefully the responses are stored locally and replayed on subsequent runs.
Re:Stop requiring only one assertion per unit test: Multiple...
by tinyspacewizard on Saturday November 05, 2022 @09:08AM
(#33481057)
Still a bit flaky. In an OOP language mocking is appropriate or in an FP language defunctionalization.
Re:Stop requiring only one assertion per unit test: Multiple...
by mollerhoj on Saturday November 05, 2022 @01:35PM
(#33483616)
Heh 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.
Re:Stop requiring only one assertion per unit test: Multiple...
by throw_m239339 on Saturday November 05, 2022 @07:33AM
(#33480462)
> Wait - people are doing real http calls in unit tests, over a network, and complaining about multiple asserts in the test code?
I think you missed the debate a few years ago between some Java head and Ruby head about what the nature of a unit test. And let's not even get started about mocks and stubs, and whether mocks and stubs should have their own unit tests...
Re:Stop requiring only one assertion per unit test: Multiple...
by chopin on Saturday November 05, 2022 @08:05AM
(#33480671)
Where 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.
Re:Stop requiring only one assertion per unit test: Multiple...
by batiste on Saturday November 05, 2022 @08:59AM
(#33480987)
I 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...
Re:Stop requiring only one assertion per unit test: Multiple...
by int_19h on Sunday November 06, 2022 @05:29PM
(#33498144)
It's far better to have integration tests without unit tests than the other way around.
Re:Stop requiring only one assertion per unit test: Multiple...
by flqn on Saturday November 05, 2022 @09:01AM
(#33480996)
It'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.
Re:Stop requiring only one assertion per unit test: Multiple...
by warrenmiller on Saturday November 05, 2022 @09:02AM
(#33481005)
They can be mocked surely?
Re:Stop requiring only one assertion per unit test: Multiple...
by drewcoo on Saturday November 05, 2022 @09:19AM
(#33481176)
It's not nice to mock people "doing real http calls in unit tests," even if they deserve it.
Re:Stop requiring only one assertion per unit test: Multiple...
by nsoonhui on Saturday November 05, 2022 @09:31AM
(#33481289)
For mocking, the parent comment means "swapping out the external calls with dummy calls", not "laughing at the developer"
Re:Stop requiring only one assertion per unit test: Multiple...
by kevincox on Saturday November 05, 2022 @11:58AM
(#33482685)
I'm 98% sure that they understood that and it was a joke.
Re:Stop requiring only one assertion per unit test: Multiple...
by BurningFrog on Saturday November 05, 2022 @12:22PM
(#33482928)
You failed a humor unit test.
Re:Stop requiring only one assertion per unit test: Multiple...
by ThunderSizzle on Saturday November 05, 2022 @05:53PM
(#33486246)
Woops, did you see the joke fly right past you?
Re:Stop requiring only one assertion per unit test: Multiple...
by warrenmiller on Saturday November 05, 2022 @09:26AM
(#33481248)
Oh dear