embedded-postgres
embedded-postgres copied to clipboard
Question regarding Junit 5
Hi There,
Do you have any example how to use embedded-postgres with Junit5 and use custom database instead of default postgres database?
Regards,
Syed Ali
Hi, I think the usage should be the same as in the case of junit4, so it should look something like this:
@RegisterExtension
public SingleInstancePostgresExtension pg = EmbeddedPostgresExtension.singleInstance();
Or this:
@RegisterExtension
public PreparedDbExtension pg = EmbeddedPostgresExtension.preparedDatabase(FlywayPreparer.forClasspathLocation("db/my-db-schema"));
The first extension uses postgres database, the second extension creates independent databases with randomly generated names. In both cases, the database name cannot be changed by the user.
Thanks for reply, I would try this.
Regards,
Syed Ali