{"id":17887120,"url":"https://github.com/radcortez/flyway-junit5-extensions","last_synced_at":"2025-03-22T15:31:13.849Z","repository":{"id":37105118,"uuid":"267134885","full_name":"radcortez/flyway-junit5-extensions","owner":"radcortez","description":"Flyway JUnit 5 Extension to clean / migrate your database in tests.","archived":false,"fork":false,"pushed_at":"2024-07-22T04:27:34.000Z","size":335,"stargazers_count":19,"open_issues_count":13,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-18T13:28:36.277Z","etag":null,"topics":["database","flyway","junit","junit5","test","testing","tests"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/radcortez.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-26T19:36:21.000Z","updated_at":"2024-08-16T11:52:27.000Z","dependencies_parsed_at":"2024-10-28T13:39:52.748Z","dependency_job_id":"db23a2be-9571-46cf-b31f-1a50cf072405","html_url":"https://github.com/radcortez/flyway-junit5-extensions","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radcortez%2Fflyway-junit5-extensions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radcortez%2Fflyway-junit5-extensions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radcortez%2Fflyway-junit5-extensions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/radcortez%2Fflyway-junit5-extensions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/radcortez","download_url":"https://codeload.github.com/radcortez/flyway-junit5-extensions/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244978597,"owners_count":20541886,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","flyway","junit","junit5","test","testing","tests"],"created_at":"2024-10-28T13:19:08.501Z","updated_at":"2025-03-22T15:31:13.022Z","avatar_url":"https://github.com/radcortez.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/github/license/smallrye/smallrye-config.svg)](http://www.apache.org/licenses/LICENSE-2.0)\n[![Maven](https://img.shields.io/maven-central/v/com.radcortez.flyway/flyway-junit5-extension?color=green)](https://search.maven.org/artifact/com.radcortez.flyway/flyway-junit5-extension)\n[![Build](https://github.com/radcortez/flyway-junit5-extensions/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/radcortez/flyway-junit5-extensions/actions?query=workflow%3ABuild+branch%3Amain)\n\n# Flyway JUnit 5 Extensions\n\nThis extensions allows you to clean / migrate your database using Flyway during testing.\n\n## How to use it?\n\nAdd the following dependency to your project:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.radcortez.flyway\u003c/groupId\u003e\n  \u003cartifactId\u003eflyway-junit5-extension\u003c/artifactId\u003e\n  \u003cversion\u003e2.1.0\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n---\n**NOTE**: \n\nThis project depends on:\n- Flyway 10.12.0\n- JUnit Jupiter 5.10.2\n\n---\n\nAdd the `@FlywayTest` annotation to your test class or method. By default, Flyway will perform the `migrate` action \nbefore each test execution and the `clean` action after the test. This can be disabled by turning `clean = false` in \nthe `@FlywayTest` annotation.  \n\nThe only required information in the `@FlywayTest` annotation is the database information that you can supply using \nthe inner `@DataSource` annotation. In the `@DataSource` annotation you can specify the `url`, `username` and `password` \nto connect to a running database:\n\n```java\n@FlywayTest(@DataSource(url = \"jdbc:h2:mem:test\"))\nclass JUnit5Test {\n\n}\n```\n\nOr you can implement a `DataSourceProvider` and return a `DataSourceInfo` with the database connection details:\n\n```java\n@FlywayTest(@DataSource(JUnit5Test.H2DatasourceProvider.class))\nclass JUnit5Test {\n\n    static class H2DatasourceProvider implements DataSourceProvider {\n        @Override\n        public DataSourceInfo getDatasourceInfo(final ExtensionContext extensionContext) {\n            return DataSourceInfo.config(\"jdbc:h2:mem:test;MODE=PostgreSQL;DB_CLOSE_DELAY=-1\");\n        }\n    }\n}\n```\n\nThe `DataSourceProvider` will always take priority over `url`, `username` and `password` in the `@DataSource` \nannotation.\n\nThe `@FlywayTest` annotation can also be placed in a method. \n\n```java\n@FlywayTest(additionalLocations = \"db/additionalLocation\")\nvoid additionalLocations() throws Exception {\n\n}\n```\n\nWhen both the class and the method are annotated, the annotations metadata is merged with the method annotation taking \npriority over the class annotation.\n\n### Conventions\n\nThe extension uses the default path to load migration scripts from Flyway, set in `resources/db/migration`.\n\nIf you want to add specific database migrations to a particular test, you can place the migration files in \n`resources/db/` plus the fully qualified name of the test as a path. For instance \n`com/radcortez/flyway/test/junit/H2LocationTest`.\n\nAdditional migration locations can be defined using the `additionalLocations` metadata in the `@FlywayTest` annotation. \nThis will not override the default locations, but just add a location for the migration files.\n\n### Meta Annotations\n\nYou can also place the `@FlywayTest` annotation in a meta annotation and then use it in the test class.\n\n```java\n@Target(ElementType.TYPE)\n@Retention(RetentionPolicy.RUNTIME)\n@FlywayTest(value = @DataSource(url = \"jdbc:h2:mem:test\"))\npublic @interface H2 {\n\n}\n\n@H2\nclass H2MetaAnnotationTest {\n    \n}\n```\n\nThe `@H2` annotation is already available in the extension, but you need to remember to add the H2 dependency to your \nproject to be able to use an H2 database:\n\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003ecom.h2database\u003c/groupId\u003e\n  \u003cartifactId\u003eh2\u003c/artifactId\u003e\n  \u003cversion\u003e2.2.224\u003c/version\u003e\n  \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradcortez%2Fflyway-junit5-extensions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fradcortez%2Fflyway-junit5-extensions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fradcortez%2Fflyway-junit5-extensions/lists"}