Re:Generating a Java program with 90% less code
by marcus_holmes on Wednesday December 04, 2019 @11:53AM
(#21703880)
I did this, and then switched back to just running the code on a test database. I found I was writing two sets of tests: one that tested the code to see if it injected the right parameters into the SQL, and another to see if the SQL worked. It just got easier to test them both together.
[ Parent
| on HN ]
Re:Generating a Java program with 90% less code
by breischl on Wednesday December 04, 2019 @03:34PM
(#21706613)
This can become a challenge when you want to scale a dev team. You either have people conflicting in the DB, or each dev needs to set up a local DB and deal with DB migrations. Containerized DBs help with this to some extent, but it's still a maintenance headache.
There's also a tradeoff around testing error states, but that can be a wash. Some errors are easier to create with a mock, some are easier to create with the actual driver.
Re:Generating a Java program with 90% less code
by dcolkitt on Wednesday December 04, 2019 @12:38PM
(#21704537)
There are tradeoffs to this approach. When the tests break it becomes a lot harder to triangulate the origin of the problems.
Re:Generating a Java program with 90% less code
by runeks on Friday December 06, 2019 @06:14AM
(#21720763)
I don’t buy this argument.
Once you know there’s a bug, you will definitely want to write more tests, in order to find the cause. But always writing a lot of tests, which are only usable in case you find a bug, seems like wasted effort to me.
If you need to triangulate the origin, do that when it’s necessary (i.e. when your broad test fails) and not all the time.
Re:Generating a Java program with 90% less code
by GordonS on Wednesday December 04, 2019 @01:48PM
(#21705534)
I prefer to just runs tests using a real database too. They might not complete as fast as mocked out ones, but they give me much more confidence of correctness, and still complete in milliseconds.