Reputation: 201
I have some tests for my project, where not database connection is needed. Sometimes I have no Database-Connection, is it possible to not start database connection while testing to avoid the errors? The error is not a problem, the program will proceed but 2021-05-19 18:11:53.610 INFO 56965 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
takes very much time every run.
Upvotes: 0
Views: 540
Reputation: 41
What you are doing is running tests using Spring. Generally this approach is taken for so-called integration testing. This means that Spring is booted up and usually runs with an in memory database (H2). Classes containing these tests have the @SpringBootTest annotation.
If you are running tests and you do not want all of Spring to launch (there is a lot more overhead than just connecting to the database) you may want to consider running your tests using JUnit. This approach is generally used in conjunction with a mocking framework and can be used to perform unit testing. JUnit tests have the @Test annotation above them.
Upvotes: 2