I am developing a server using Spring Boot 3, but for some reason, the test code is not running properly and is throwing an error as mentioned in the title.
I have seen various solutions on the internet since it seems to be a common error, but none of them have worked.
How can I resolve this issue?
I already tried to change Run tests using
Gradle -> IntelliJ IDEA, but it also didn’t work.
build.gradle
<code>plugins {
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
}
jar.enabled(true)
bootJar.enabled(true)
dependencies {
implementation project(':joon-core')
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation:3.2.4'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0'
implementation 'org.apache.poi:poi-ooxml:5.2.5'
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3"
// Mockito
testImplementation "org.mockito:mockito-inline"
testImplementation "org.mockito:mockito-core"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
</code>
<code>plugins {
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
}
jar.enabled(true)
bootJar.enabled(true)
dependencies {
implementation project(':joon-core')
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation:3.2.4'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0'
implementation 'org.apache.poi:poi-ooxml:5.2.5'
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3"
// Mockito
testImplementation "org.mockito:mockito-inline"
testImplementation "org.mockito:mockito-core"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
</code>
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.4'
id 'io.spring.dependency-management' version '1.1.4'
}
jar.enabled(true)
bootJar.enabled(true)
dependencies {
implementation project(':joon-core')
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-validation:3.2.4'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.4.0'
implementation 'org.apache.poi:poi-ooxml:5.2.5'
implementation 'org.springframework.boot:spring-boot-starter-security'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation "org.mybatis.spring.boot:mybatis-spring-boot-starter-test:3.0.3"
// Mockito
testImplementation "org.mockito:mockito-inline"
testImplementation "org.mockito:mockito-core"
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
Test
<code>@SpringBootTest
class AdminApplicationTest {
@Autowired
private AdminService adminService;
@Test
void given_when_then() {
adminService.execute("ID", "joon");
}
}
</code>
<code>@SpringBootTest
class AdminApplicationTest {
@Autowired
private AdminService adminService;
@Test
void given_when_then() {
adminService.execute("ID", "joon");
}
}
</code>
@SpringBootTest
class AdminApplicationTest {
@Autowired
private AdminService adminService;
@Test
void given_when_then() {
adminService.execute("ID", "joon");
}
}
Error