Charlie
Charlie

Reputation: 3374

How to disable Javers for integration tests?

I am using Javers 3.11.2 with Spring Boot 1.5.17. When I am trying to run integration tests on an embedded database I still see that Javers tables are getting created each time.

Is there a way I can disable Javers during these tests so that these tables will not be created each time?

Upvotes: 2

Views: 2297

Answers (2)

Bartek Walacik
Bartek Walacik

Reputation: 3496

There is the easy way, put:

javers:
  sqlSchemaManagementEnabled: false

in your application-test.yml. See https://javers.org/documentation/spring-boot-integration/

Upvotes: 4

Mark Bramnik
Mark Bramnik

Reputation: 42431

Disclaimer: I've never used Javers.

In general, disabling something in "integration tests" means that you don't want to load some beans (of Javers in this case).

This means in turn that you have to exclude them from the list of configurations spring boot works with.

If you're using javers autoconfiguration module, it has to provide in its own "spring.factories" file (can be found inside the jar) a file for autoconfiguration.

Find its java code and see whether it has some "@Conditional on something (property beans, etc.)" If it has than create a profile for integration test that will configure the beans in a way that conditional in javers won't pass and the bean won't be created as a consequence

If it doesn't have a conditional on something like this, you'll have to exclude the whole configuration. Its usually can be done by annotation @SpringBootApplication(exclude=<JaversAutoconfiguration goes here>

This will, however, turn it off also for production usage, which is obviously not something that you want. So for "production" profile, you'll have to import it as a regular configuration (not an autoconfiguration), for integration test profile you won't need this.

Upvotes: 2

Related Questions