This enables IDEA to get information about certain things in your code and apply the correct validation, information and/or formatting.
We only use it for one thing so far: Marking strings as SQL. That enables IDEA to recognize it and apply the correct highlighting.
The below example shows a wrapper method we have for JDBI, and because of the @Language annotation IDEA knows that it should apply SQL syntax highlighting.
This is a re-post of an original Medium article. As I am moving my content here I will re-post some content.
We aim for fast tests, ideally completing all tests within 30 seconds. Currently, our tests take 1 minute and 30 seconds, but we are determined to to get ther. 😃 To achieve this goal, we must reduce the overhead of each run.
Read on to learn about the techniques we use to speed up DB connection handling and migrations.
Establishing connections takes time, and the overhead of checking migrations before each test can also be time-consuming. We usually run a persistent DB in a Docker container, so we only have to create connections and migrate once for each run. We do use Test Containers if no DB is available, but it is slower. Every millisecond counts. 😃
Therefore we looked for a way to minimize this when running thousands of tests.
JUnit enforces strict isolation between tests so you can’t just inherit a class or something and get a shared value across the run. But as we knew Spring caches contexts across tests, there had to be a way. JUnit ParameterResolvers come to the rescue:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The Database and Config objects are just custom wrappers around Hikari, JDBI and Liquibase. You can store the JDBI object or a Hikari connection pool directly by changing the code above and adjustinng the class type. The important part is putting it in the store so it is persisted across runs.
To use it you do something like this:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
And I think maybe it’s time to bring things back here. If you by any chance are actually following this site you might want to check what I have been writing about at Medium since last time.
If you dig into the archives here, I actually have articles dating back to 2004 (see year links at the bottom). It can be weird and sometimes even embarrassing to read them, but at leas they are out there. 🙂