¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Re: unit test condition on sql statement


 

Hi,
?
What does "almost as fast" mean in practice?

A few stats about our codebase in this 14 months old Java project:
- we have almost 800 classes of production code with ~32K LOC (empty lines excluded)
- we have almost 500 classes of tests with ~36K LOC

- JUnit reports 2400+ tests in these 500 classes (some are parameterized tests)
- the test coverage is about 80%
- out of those 500 classes about 70 are those that run against a real Postgres database
- the whole test suite runs in under 12 seconds on my M1 Mac Mini, almost as fast on an i7 laptop with Ubuntu and in about 1minute on older Macs.

This has been sufficiently fast for our team. We know a few tricks we can apply to speed it up slightly if needed.?
To run a single DB-bound test - there is a slight overhead - it probably takes a few seconds. But this has never been a problem for us and there is no tendency in the team to avoid writing them. Sometimes it actually feels a welcome change from mocking.

One additional benefit of those tests is that we have started to rely and use more specific SQL features in our code. E.g. triggers, constraints, custom functions, etc. This has allowed us to move some logic closer to the data while maintaining the confidence that TDD gives us in building those. We have not yet seen a need for a view but that probably lies on the horizon and I can create that view with a DB migration in true TDD style and make sure that the data that I insert into the tables is available properly via the trigger.

Best regards,
Erik ?


Join [email protected] to automatically receive all group messages.