embedded-postgres icon indicating copy to clipboard operation
embedded-postgres copied to clipboard

Question regarding Junit 5

Open sfali opened this issue 5 years ago • 2 comments

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

sfali avatar Jun 21 '20 00:06 sfali

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.

tomix26 avatar Jun 26 '20 15:06 tomix26

Thanks for reply, I would try this.

Regards,

Syed Ali

sfali avatar Jul 03 '20 12:07 sfali