У меня есть тест JUnit 5, который не работает, он зависает, как показано ниже:
2020-04-03 16:53:23.207 INFO 2788 --- [ main] .i.p.d.r.CustomerReferenceRepositoryTest :
No active profile set, falling back to default profiles: default
2020-04-03 16:53:24.153 INFO 2788 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate :
Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2020-04-03 16:53:24.590 INFO 2788 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate :
Finished Spring Data repository scanning in 372ms. Found 8 JPA repository interfaces.
2020-04-03 16:53:26.078 INFO 2788 --- [ main] com.zaxxer.hikari.HikariDataSource :
HikariPool-1 - Starting...
2020-04-03 16:53:27.667 INFO 2788 --- [ main] com.zaxxer.hikari.HikariDataSource :
HikariPool-1 - Start completed.
2020-04-03 16:53:27.997 INFO 2788 --- [ main] o.hibernate.jpa.internal.util.LogHelper :
HHH000204: Processing PersistenceUnitInfo [name: default]
2020-04-03 16:53:28.392 INFO 2788 --- [ main] org.hibernate.Version :
HHH000412: Hibernate ORM core version 5.4.12.Final
2020-04-03 16:53:28.866 INFO 2788 --- [ main] o.hibernate.annotations.common.Version :
HCANN000001: Hibernate Commons Annotations {5.1.0.Final}
2020-04-03 16:53:29.180 INFO 2788 --- [ main] org.hibernate.dialect.Dialect :
HHH000400: Using dialect: org.hibernate.dialect.Oracle12cDialect
Тест помечается так:
@DataJpaTest
@AutoConfigureTestDatabase(replace = Replace.NONE)
@ContextConfiguration(classes = TestDALConfig.class)
class CustomerReferenceRepositoryTest {
Тест получает застрял, и когда я остановил его вручную, я получил следующее сообщение об ошибке:
Не найдено тестов с бегуном теста 'JUnit 5'
Сам тест очень прост:
@Test
public void notNull() {
assertThat(customerReferenceRepository).isNotNull();
}
Полный модульный тест
package <removed>.payment.dal.repository;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase;
import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace;
import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest;
import org.springframework.test.context.ContextConfiguration;
import aero.sita.pts.ir.payment.config.TestDALConfig;
@DataJpaTest
@AutoConfigureTestDatabase(replace = Replace.NONE)
@ContextConfiguration(classes = TestDALConfig.class)
class CustomerReferenceRepositoryTest {
@Autowired
private CustomerReferenceRepository customerReferenceRepository;
public CustomerReferenceRepositoryTest() {
super();
}
@Test
public void notNull() {
assertThat(customerReferenceRepository).isNotNull();
}
}
Maven pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<artifactId>payment-dal-api</artifactId>
<name>payment-dal-api</name>
<description>payment-dal-api</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
<ojdbc7.version>12.1.0.2</ojdbc7.version>
</properties>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>${ojdbc7.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
TestDALConfig
@Configuration
@EnableJpaRepositories(basePackageClasses=ConfigRepository.class)
public class TestDALConfig {
public TestDALConfig() {
super();
}
}
CustomerReferenceRepository
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import aero.sita.pts.ir.payment.dal.dto.CustomerReferenceDTO;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
@Repository
public interface CustomerReferenceRepository extends PagingAndSortingRepository<CustomerReferenceDTO, Long> {
}
Может кто-нибудь пролить какой-то свет на это? Спасибо