Skip to content
Snippets Groups Projects
Commit 3b0f503f authored by Mingyuan Chen's avatar Mingyuan Chen
Browse files

Merge remote-tracking branch 'origin/cmy' into cmy

parents 9c0e4438 f08d251a
No related branches found
No related tags found
No related merge requests found
......@@ -13,12 +13,23 @@ test {
}
}
jacoco {
toolVersion = "0.8.10" // 确保设置版本,Jenkins 有时会要求
}
jacocoTestReport {
dependsOn test // ⚠️ 一定要先执行测试任务
dependsOn test
reports {
xml.required = true
html.required = true
csv.required = false
xml.outputLocation = layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml")
}
// 确保 Jenkins 能找到 class 和 source 路径
classDirectories.setFrom(fileTree("${buildDir}/classes/java/main"))
sourceDirectories.setFrom(files("src/main/java"))
executionData.setFrom(fileTree(buildDir).include("/jacoco/test.exec"))
}
group = 'com.cardiff.client_project'
......@@ -49,16 +60,11 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
//implementation 'org.seleniumhq.selenium:selenium-java:4.8.0'
testImplementation("io.github.bonigarcia:webdrivermanager:5.2.0")
testImplementation group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.32'
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.0'
}
tasks.named('test') {
useJUnitPlatform()
}
package com.cardiff.cmyTest;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.TestPropertySource;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.MediaType;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@SpringBootTest
@AutoConfigureMockMvc
@TestPropertySource(properties = {
"spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver",
"spring.datasource.url=jdbc:mysql://localhost:3306/healthcare?useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=UTC",
"spring.datasource.username=root",
"spring.datasource.password=472500"
})
public class HospitalControllerIntegrationTest {
@Autowired
private MockMvc mockMvc;
@Autowired
private ObjectMapper objectMapper;
@Test
public void testGetAllHospitalsIntegration() throws Exception {
mockMvc.perform(get("/commonAdmin/hospital/all")
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$").isArray());
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment