Skip to content

Commit 78158b2

Browse files
authored
Merge pull request #333 from zonkyio/#230-junit5-highlight
#230 Update readme with JUnit 5 examples and docs improvements
2 parents 7fa7951 + 67ad02a commit 78158b2

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

README.md

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,11 @@ The primary goal of this project is to make it easier to write Spring-powered in
66

77
## Supported Integrations
88

9-
* Supports both `Spring` and `Spring Boot` frameworks
10-
* Spring `4.3.8` - `7.0.x`
11-
* Spring Boot `1.4.6` - `4.0.x`
12-
* Supports multiple different databases
13-
* [PostgreSQL](#postgresql), [MSSQL](#microsoft-sql-server), [MySQL](#mysql), [MariaDB](#mariadb), [H2](#h2), [HSQLDB](#hsqldb), [Derby](#derby)
14-
* Supports multiple database providers
15-
* [Docker / Testcontainers](#using-docker-provider-default), [Zonky](#using-zonky-provider-previous-default), [OpenTable](#using-opentable-provider), [Yandex](#using-yandex-provider)
16-
* Supports various database migration tools
17-
* [Flyway](#flyway), [Liquibase](#liquibase), [Spring `@Sql` annotation](#using-spring-sql-annotation) and others
9+
* 🌱 **Frameworks:** `Spring` `4.3.8` - `7.0.x`, `Spring Boot` `1.4.6` - `4.0.x`
10+
* 🧪 **Testing frameworks:** `JUnit 5`, `JUnit 4`, `TestNG` and any other supported by Spring
11+
* 🗄️ **Databases:** [PostgreSQL](#postgresql), [MSSQL](#microsoft-sql-server), [MySQL](#mysql), [MariaDB](#mariadb), [H2](#h2), [HSQLDB](#hsqldb), [Derby](#derby)
12+
* 🐳 **Database providers:** [Docker (Testcontainers)](#using-docker-provider-default), [Embedded (Zonky)](#using-zonky-provider-previous-default), ~~[OpenTable](#using-opentable-provider)~~, ~~[Yandex](#using-yandex-provider)~~
13+
* 🔄 **Migration tools:** [Flyway](#flyway), [Liquibase](#liquibase), [Spring `@Sql` annotation](#using-spring-sql-annotation) and others
1814

1915
## Main Goals
2016

@@ -81,7 +77,7 @@ The configuration of the embedded database is driven by the `@AutoConfigureEmbed
8177
A new data source will be created and injected into all related components. You can also inject it into a test class as shown below.
8278

8379
```java
84-
@RunWith(SpringRunner.class)
80+
@ExtendWith(SpringExtension.class)
8581
@AutoConfigureEmbeddedDatabase
8682
public class EmptyDatabaseIntegrationTest {
8783

@@ -98,7 +94,7 @@ In case the test class uses a spring context that already contains a data source
9894
The newly created data source bean will be injected into all related components, and you can also inject it into a test class.
9995

10096
```java
101-
@RunWith(SpringRunner.class)
97+
@ExtendWith(SpringExtension.class)
10298
@AutoConfigureEmbeddedDatabase
10399
@ContextConfiguration("path/to/application-config.xml")
104100
public class EmptyDatabaseIntegrationTest {
@@ -114,7 +110,7 @@ The `@AutoConfigureEmbeddedDatabase` is a repeatable annotation, so you can anno
114110
Each of them may have completely different configuration parameters, including the database provider as demonstrated in the example below.
115111

116112
```java
117-
@RunWith(SpringRunner.class)
113+
@ExtendWith(SpringExtension.class)
118114
@AutoConfigureEmbeddedDatabase(beanName = "dataSource1")
119115
@AutoConfigureEmbeddedDatabase(beanName = "dataSource2", provider = ZONKY)
120116
@AutoConfigureEmbeddedDatabase(beanName = "dataSource3", provider = YANDEX)
@@ -142,17 +138,17 @@ and whether the refresh should take place before or after the test execution.
142138
Please note that by default, if you do not specify the refresh mode explicitly, all tests in the project share the same database.
143139

144140
```java
145-
@RunWith(SpringRunner.class)
141+
@ExtendWith(SpringExtension.class)
146142
@AutoConfigureEmbeddedDatabase(refresh = AFTER_EACH_TEST_METHOD)
147143
public class EmptyDatabaseIntegrationTest {
148144

149145
@Test
150-
public void testMethod1() {
146+
void testMethod1() {
151147
// fresh database
152148
}
153149

154150
@Test
155-
public void testMethod2() {
151+
void testMethod2() {
156152
// fresh database
157153
}
158154
}
@@ -173,7 +169,7 @@ But if the `@DataJpaTest` annotation is used together with the `@AutoConfigureEm
173169
the in-memory database is automatically disabled and replaced with an embedded database.
174170

175171
```java
176-
@RunWith(SpringRunner.class)
172+
// @ExtendWith(SpringExtension.class) // not needed — @DataJpaTest, @JdbcTest, @JsonTest, @SpringBootTest already include this extension
177173
@DataJpaTest
178174
@AutoConfigureEmbeddedDatabase
179175
public class SpringDataJpaAnnotationTest {
@@ -220,7 +216,7 @@ You can also consider creating a custom [composed annotation](https://github.com
220216
Spring provides the `@Sql` annotation that can be used to annotate a test class or test method to configure sql scripts to be run against an embedded database during tests.
221217

222218
```java
223-
@RunWith(SpringRunner.class)
219+
@ExtendWith(SpringExtension.class)
224220
@Sql({"/test-schema.sql", "/test-user-data.sql"})
225221
@AutoConfigureEmbeddedDatabase
226222
public class SpringSqlAnnotationTest {
@@ -238,7 +234,7 @@ Please note that if you declare the annotation on a class, all tests within the
238234
Alternatively, you can also use the [refresh mode](#refreshing-the-database-during-tests).
239235

240236
```java
241-
@RunWith(SpringRunner.class)
237+
@ExtendWith(SpringExtension.class)
242238
@FlywayTest // performs clean and migrate operations, with the same effect as the refresh mode
243239
@AutoConfigureEmbeddedDatabase
244240
@ContextConfiguration("path/to/application-config.xml")
@@ -518,7 +514,7 @@ This is the default provider, so you do not have to do anything special,
518514
just use the `@AutoConfigureEmbeddedDatabase` annotation in its basic form without specifying any provider.
519515

520516
```java
521-
@RunWith(SpringRunner.class)
517+
@ExtendWith(SpringExtension.class)
522518
@AutoConfigureEmbeddedDatabase
523519
public class DefaultProviderIntegrationTest {
524520
// class body...
@@ -567,7 +563,7 @@ public class EmbeddedPostgresConfiguration {
567563
```
568564

569565
```java
570-
@RunWith(SpringRunner.class)
566+
@ExtendWith(SpringExtension.class)
571567
@AutoConfigureEmbeddedDatabase
572568
@ContextConfiguration(classes = EmbeddedPostgresConfiguration.class)
573569
public class EmbeddedPostgresIntegrationTest {
@@ -591,7 +587,7 @@ Before you use the Zonky provider, you have to add the following Maven dependenc
591587
Then, you can use the `@AutoConfigureEmbeddedDatabase` annotation to set up the `DatabaseProvider.ZONKY` provider.
592588

593589
```java
594-
@RunWith(SpringRunner.class)
590+
@ExtendWith(SpringExtension.class)
595591
@AutoConfigureEmbeddedDatabase(provider = ZONKY)
596592
public class ZonkyProviderIntegrationTest {
597593
// class body...
@@ -646,7 +642,7 @@ public class EmbeddedPostgresConfiguration {
646642
```
647643

648644
```java
649-
@RunWith(SpringRunner.class)
645+
@ExtendWith(SpringExtension.class)
650646
@AutoConfigureEmbeddedDatabase(provider = ZONKY)
651647
@ContextConfiguration(classes = EmbeddedPostgresConfiguration.class)
652648
public class EmbeddedPostgresIntegrationTest {
@@ -656,6 +652,8 @@ public class EmbeddedPostgresIntegrationTest {
656652

657653
### Using OpenTable Provider
658654

655+
> **Deprecated:** OpenTable provider has been deprecated in favor of Embedded (Zonky) provider and is scheduled to be removed in the next major version.
656+
659657
Before you use the OpenTable provider, you have to add the following Maven dependency:
660658

661659
```xml
@@ -670,7 +668,7 @@ Before you use the OpenTable provider, you have to add the following Maven depen
670668
Then, you can use the `@AutoConfigureEmbeddedDatabase` annotation to set up the `DatabaseProvider.OPENTABLE` provider.
671669

672670
```java
673-
@RunWith(SpringRunner.class)
671+
@ExtendWith(SpringExtension.class)
674672
@AutoConfigureEmbeddedDatabase(provider = OPENTABLE)
675673
public class OpenTableProviderIntegrationTest {
676674
// class body...
@@ -696,7 +694,7 @@ public class EmbeddedPostgresConfiguration {
696694
```
697695

698696
```java
699-
@RunWith(SpringRunner.class)
697+
@ExtendWith(SpringExtension.class)
700698
@AutoConfigureEmbeddedDatabase(provider = OPENTABLE)
701699
@ContextConfiguration(classes = EmbeddedPostgresConfiguration.class)
702700
public class EmbeddedPostgresIntegrationTest {
@@ -706,6 +704,8 @@ public class EmbeddedPostgresIntegrationTest {
706704

707705
### Using Yandex Provider
708706

707+
> **Deprecated:** Yandex provider has been deprecated in favor of Embedded (Zonky) provider and is scheduled to be removed in the next major version.
708+
709709
Before you use the Yandex provider, you have to add the following Maven dependency:
710710

711711
```xml
@@ -720,7 +720,7 @@ Before you use the Yandex provider, you have to add the following Maven dependen
720720
Then, you can use the `@AutoConfigureEmbeddedDatabase` annotation to set up the `DatabaseProvider.YANDEX` provider.
721721

722722
```java
723-
@RunWith(SpringRunner.class)
723+
@ExtendWith(SpringExtension.class)
724724
@AutoConfigureEmbeddedDatabase(provider = YANDEX)
725725
public class YandexProviderIntegrationTest {
726726
// class body...

0 commit comments

Comments
 (0)