Move the unit tests from commandlinerunner to separate project
See gh-142
This commit is contained in:
@@ -7,9 +7,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
public class CommandlinerunnerApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(CommandlinerunnerApplication.class);
|
||||
System.setProperty("main.ran", "true");
|
||||
application.run(args);
|
||||
SpringApplication.run(CommandlinerunnerApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
1
boot/tcf/README.adoc
Normal file
1
boot/tcf/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
Tests if Spring Boot's TestContext Framework is working
|
||||
16
boot/tcf/build.gradle
Normal file
16
boot/tcf/build.gradle
Normal file
@@ -0,0 +1,16 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'org.springframework.boot'
|
||||
id 'org.springframework.aot.smoke-test'
|
||||
id 'org.graalvm.buildtools.native'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(platform(org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES))
|
||||
implementation("org.springframework.boot:spring-boot-starter")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
appTestImplementation(project(":aot-smoke-test-support"))
|
||||
appTestImplementation("org.awaitility:awaitility:4.2.0")
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.boot.tcf;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class BootTcfApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication application = new SpringApplication(BootTcfApplication.class);
|
||||
System.setProperty("main.ran", "true");
|
||||
application.run(args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.commandlinerunner;
|
||||
package com.example.boot.tcf;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -7,19 +7,12 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.UseMainMethod;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, useMainMethod = UseMainMethod.ALWAYS, args = "--test.args=1")
|
||||
class CommandlinerunnerApplicationTests {
|
||||
|
||||
@Test
|
||||
void mainShouldRun() {
|
||||
String property = System.getProperty("main.ran", "false");
|
||||
assertThat(property).isEqualTo("true");
|
||||
}
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, args = "--test.args=1")
|
||||
class ArgsTest {
|
||||
|
||||
@Test
|
||||
void shouldPassArgs(@Autowired ApplicationArguments applicationArguments) {
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.example.boot.tcf;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.context.SpringBootTest.UseMainMethod;
|
||||
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@SpringBootTest(webEnvironment = WebEnvironment.NONE, useMainMethod = UseMainMethod.ALWAYS)
|
||||
class MainMethodTests {
|
||||
|
||||
@Test
|
||||
void mainShouldRun() {
|
||||
String property = System.getProperty("main.ran", "false");
|
||||
assertThat(property).isEqualTo("true");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.commandlinerunner;
|
||||
package com.example.boot.tcf;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.commandlinerunner;
|
||||
package com.example.boot.tcf;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
Reference in New Issue
Block a user