I have a test that is testing parts of a spring application. It is using SpringRunner and the annotaion @SpringBootTest so it is starting a full spring server.
Problem is that the test is being executed by a server that does not have access to the database, so I am getting a lot of connection timeouts that is slowing down the test.
The connection issues in itself isn't really a problem as the tests are mocking the calls to the database, and so they are not relying on the connection being there. It is just that the tests are slow(and ugly) with it.
So the tests looks kind of like this:
@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class DispatcherTest
and it uses this property file
spring.datasource.url:jdbc:oracle:thin:@100.32.13.32:1521:TEST
spring.datasource.username:sa
spring.datasource.password:password
spring.datasource.driver-class-name:oracle.jdbc.OracleDriver
spring.jpa.database-platform:org.hibernate.dialect.Oracle10gDialect
I think that the issue is that there are a lot of different JPA repositories that are being scanned like this
@EnableJpaRepositories("package.*")
So is there any fancy way of telling spring not to connect to the database or do I have to mock every single JPA repository class?
Aucun commentaire:
Enregistrer un commentaire