[英]Running Spring Boot Tests from CLI using Gradle
I am learning Spring Boot and have a beginner's question on how to run from CLI.我正在学习 Spring Boot 并且有一个关于如何从 CLI 运行的初学者问题。
In IntelliJ, when using the JUnit run configuration or from the right-click context menu, I see Spring Boots's distinctive logo in the console.在 IntelliJ 中,当使用 JUnit 运行配置或从右键单击上下文菜单中时,我在控制台中看到 Spring Boots 的独特徽标。 If I run using
.gradlew clean test
the test runs exactly the same but without any spring-y stuff.如果我使用
.gradlew clean test
运行,则测试运行完全相同,但没有任何 spring-y 东西。
Test Class:测试 Class:
@SpringBootTest
@Profile("dev")
class SpringBasicApplicationTests {
@Autowired
private MainPage mainPage;
@Value("${app.url}")
private String appUrl;
@Autowired
private WebDriver driver;
@Test
void performLoginTest() {
mainPage.performLogin();
}
}
build.gradle
plugins {
id 'org.springframework.boot' version '2.4.5'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
id 'io.freefair.lombok' version '5.3.0'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.ea'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter:2.4.3'
implementation 'io.github.bonigarcia:webdrivermanager:3.8.1'
implementation 'org.seleniumhq.selenium:selenium-java:3.141.59'
testImplementation 'org.springframework.boot:spring-boot-starter-test:2.4.3'
testImplementation 'org.testng:testng:7.1.0'
testImplementation 'org.testcontainers:junit-jupiter:1.15.1'
testImplementation 'org.testcontainers:selenium:1.15.1'
}
test {
useJUnitPlatform()
filter{
includeTestsMatching "com.ea.SpringBasic.SpringBasicApplicationTests"
}
}
Sorry for the noob question - how do I bootstrap this to run nicely from Gradle so I can start to run from a CI context (Jenkins)?抱歉这个菜鸟问题 - 我如何引导它从 Gradle 很好地运行,以便我可以开始从 CI 上下文(Jenkins)运行?
By default running gradlew clean test
you won't see a lot of output.默认运行
gradlew clean test
你不会看到很多 output。
Running with gradlew clean test --info
you will see more output, including the Spring logo使用
gradlew clean test --info
运行,您将看到更多 output,包括 Spring 徽标
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.