JPA JUnit5 - Extension

This extension allow you to run Jpa integration tests without having to start any EntityManagerFactory for each test class.

Лицензия

Лицензия

Категории

Категории

JUnit Тестирование компонентов
Группа

Группа

io.github.jlmc
Идентификатор

Идентификатор

jpa-junit5-extension
Последняя версия

Последняя версия

1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

JPA JUnit5 - Extension
This extension allow you to run Jpa integration tests without having to start any EntityManagerFactory for each test class.

Скачать jpa-junit5-extension

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/io.github.jlmc/jpa-junit5-extension/ -->
<dependency>
    <groupId>io.github.jlmc</groupId>
    <artifactId>jpa-junit5-extension</artifactId>
    <version>1.1</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.jlmc/jpa-junit5-extension/
implementation 'io.github.jlmc:jpa-junit5-extension:1.1'
// https://jarcasting.com/artifacts/io.github.jlmc/jpa-junit5-extension/
implementation ("io.github.jlmc:jpa-junit5-extension:1.1")
'io.github.jlmc:jpa-junit5-extension:jar:1.1'
<dependency org="io.github.jlmc" name="jpa-junit5-extension" rev="1.1">
  <artifact name="jpa-junit5-extension" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.jlmc', module='jpa-junit5-extension', version='1.1')
)
libraryDependencies += "io.github.jlmc" % "jpa-junit5-extension" % "1.1"
[io.github.jlmc/jpa-junit5-extension "1.1"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.junit.jupiter : junit-jupiter-api Необязательный jar 5.6.2

provided (1)

Идентификатор библиотеки Тип Версия
javax.persistence : javax.persistence-api jar 2.2

Модули Проекта

Данный проект не имеет модулей.

Java CI with Maven Maven Central

JPA JUnit 5 Extensions

This extension allow you to run Jpa integration tests without having to start any EntityManagerFactory for each test class.

How to use it?

Add the following dependency to your project:

<dependency>
  <groupId>io.github.jlmc</groupId>
  <artifactId>jpa-junit5-extension</artifactId>
  <version>1.1</version>
  <scope>test</scope>
</dependency>

NOTE:

This project depends on:

  • javax.persistence-api 2.2
  • JUnit Jupiter 5.6.2

Add the @JpaTest annotation to your test class. By default, Jpa EntityManagerFactory will be started in the callback BeforeAllCallback#beforeAll. Using the @JpaTest annotation to your test class, allows you to inject an instance of EntityManager, EntityManagerFactory or JpaProvider for each execution of the test methods:

@JpaTest( persistenceUnit = "it" )
class JUnit5Test {

    @JpaContext
    private JpaProvider jpa;

    @Test
    void createBook() {
        EntityManager em = jpa.em();
        em.getTransaction().begin();

        em.persist(new Book().setTitle("The Great Gatsby"));

        em.getTransaction().commit();

        em.close();
    }
}

Версии библиотеки

Версия
1.1
1.0