Re:Observations on the testing culture of test-driven develo...
by canhascodez on Wednesday August 15, 2018 @01:24AM
(#17763933)
I would like to believe this, so let's kick it about. I hypothesize that you just get to move state around: that having a pile of perfectly functional code means that you then have to setup/inject a lot of stateful stuff in order to actually test anything, and the complexity of the code/testcode system is conserved. Is there a good way to test this? Is the whole system easier or harder to understand if the stateful bits are isolated?
Re:Observations on the testing culture of test-driven develo...
by u801e on Wednesday August 15, 2018 @08:31AM
(#17765506)
In the example I gave, the state is held in the outer method. That is, the connections with the HTTP client and the database.
The methods that process the data from the request, generate the database query, process the data returned from the database and generate the HTTP response can all be tested by setting up the function parameters and asserting on the return value. Setting up mocks to do things like assert that the function calls another method with a particular set of parameters is not necessary.
As for testing interactions with the HTTP client and database, one can set up an environment that runs a actual HTTP client and an actual database server (populating it with test data). Testing against actual implementations is always better than testing against mocks.
Re:Observations on the testing culture of test-driven develo...
by canhascodez on Thursday August 16, 2018 @03:45PM
(#17777878)
It sounds like, "if you wish to make an apple pie from scratch, you must first invent the universe." But, hey, if it's good enough for the universe, who are we to try to improve on that?
Re:Observations on the testing culture of test-driven develo...
by Retra on Wednesday August 15, 2018 @01:54AM
(#17764022)
It depends where your state is. If it's all in one place, set-able in one language, then it's probably no worse. But if your state is spread out across 30 different config files for 12 different versions of software, spread among multiple machines... good luck getting it setup for reproducible tests.
Re:Observations on the testing culture of test-driven develo...
by flukus on Wednesday August 15, 2018 @01:14AM
(#17763908)
I'd say procedural more than functional, it drives you to avoid encapsulated state and that's about it, unless of course you want to define C's level of abstraction as functional :)
Almost sounds like functional code is the easiest to test code...