Skip to content

How to disable Datasource on certain @MicronautTest-annotated test? #2856

Answered by sdelamo
Nahuel92 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, move everything datasource related to outside of application.properties.

In the test which use persistence annotate them with

@Property(name = "datasources.default.password", value = "")
@Property(name = "datasources.default.dialect", value = "H2")
@Property(name = "datasources.default.schema-generate", value = "CREATE_DROP")
@Property(name = "datasources.default.url", value = "jdbc\:h2\:mem\:devDb;LOCK_TIMEOUT\=10000;DB_CLOSE_ON_EXIT\=FALSE")
@Property(name = "datasources.default.username", value = "sa")
@Property(name = "datasources.default.driver-class-name", value = "org.h2.Driver")
@MicronautTest
...
..

and have:

application-dev.properties to run the app locally with datasource …

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
7 replies
@sdelamo
Comment options

@Nahuel92
Comment options

@sdelamo
Comment options

Answer selected by Nahuel92
@Nahuel92
Comment options

@eyalgo
Comment options

@sdelamo
Comment options

@Nahuel92
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2855 on March 28, 2024 09:48.