Java 升级JUNIT 5后没有单元测试
我将jhipster项目从5.8.2版升级到6.1.0版 然后,我按照以下链接升级我的单元测试类: 当我启动时:Java 升级JUNIT 5后没有单元测试,java,spring-boot,jhipster,junit5,Java,Spring Boot,Jhipster,Junit5,我将jhipster项目从5.8.2版升级到6.1.0版 然后,我按照以下链接升级我的单元测试类: 当我启动时: ./gradlew test 没有启动单元测试 类单元测试样本: import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.springfr
./gradlew test
没有启动单元测试
类单元测试样本:
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.web.PageableHandlerMethodArgumentResolver;
import org.springframework.http.MediaType;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.Validator;
import javax.persistence.EntityManager;
import java.util.ArrayList;
import java.util.List;
import static fr.project.app.web.rest.TestUtil.createFormattingConversionService;
import static org.assertj.core.api.Assertions.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.mockito.Mockito.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
/**
* Integration tests for the {@Link WebServiceResource} REST controller.
*/
@SpringBootTest(classes = ProjectApp.class)
public class WebServiceResourceIntTest {
这是我的build.gradle文件:
import org.gradle.internal.os.OperatingSystem
buildscript {
repositories {
mavenLocal()
mavenCentral()
gradlePluginPortal()
maven { url "http://repo.spring.io/plugins-release" }
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${spring_boot_version}"
classpath "io.spring.gradle:propdeps-plugin:0.0.10.RELEASE"
//jhipster-needle-gradle-buildscript-dependency - JHipster will add additional gradle build script plugins here
}
}
test {
useJUnitPlatform()
exclude "**/*IT*", "**/*IntTest*", "**/*CucumberIT*"
testLogging {
events 'FAILED', 'SKIPPED'
}
// uncomment if the tests reports are not generated
// see https://github.com/jhipster/generator-jhipster/pull/2771 and https://github.com/jhipster/generator-jhipster/pull/4484
// ignoreFailures true
reports.html.enabled = false
}
repositories {
mavenLocal()
mavenCentral()
jcenter()
//jhipster-needle-gradle-repositories - JHipster will add additional repositories
}
dependencies {
// import JHipster dependencies BOM
implementation platform("io.github.jhipster:jhipster- dependencies:${jhipster_dependencies_version}" )
// Use ", version: jhipster_dependencies_version, changing: true" if you want
// to use a SNAPSHOT release instead of a stable release
implementation group: "io.github.jhipster", name: "jhipster-framework"
....
implementation "org.springframework.boot:spring-boot-starter-cache"
testImplementation ("org.springframework.boot:spring-boot-starter-test") {
exclude module: "junit"
exclude group: "com.vaadin.external.google", module: "android-json"
}
testImplementation "org.springframework.security:spring-security-test"
testImplementation "org.springframework.boot:spring-boot-test"
testImplementation "org.junit.jupiter:junit-jupiter-engine"
testImplementation "org.junit.vintage:junit-vintage-engine"
testImplementation "org.assertj:assertj-core"
testImplementation "junit:junit"
testImplementation "org.mockito:mockito-core"
testImplementation "org.hamcrest:hamcrest-library"
testImplementation "com.h2database:h2"
//jhipster-needle-gradle-dependency - JHipster will add additional
}
wrapper {
gradleVersion = "5.4.1"
}
...
compileJava.dependsOn processResources
processResources.dependsOn bootBuildInfo
升级jhipster已自动修改此文件
你有什么想法吗?我不得不补充:
classpath 'org.junit.platform:junit-platform-gradle-plugin:1.2.0'
构建脚本依赖关系。你的gradle配置是什么样子的?@Darrenforsyth我编辑了我的帖子,回答你的问题