I run IntelliJ 2023.3.3. The IDE settings are set to incorporate the file header first:
However, when a test file is created via Ctrl + Shift + T the header is inserted after the package and imported in the new file.
How can this be fixed?
There are JUnit 3/4/5 Test Class templates under the Code tab on your screenshot, you need to adjust them as well.