From 6d1293653294811b0d587b85c2166feaf292481e Mon Sep 17 00:00:00 2001 From: bunny <1319900154@qq.com> Date: Tue, 25 Mar 2025 14:34:21 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E6=B5=8B=E8=AF=95=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=A1=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bunny/services/controller/LoginTest.java | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 service/src/test/java/cn/bunny/services/controller/LoginTest.java diff --git a/service/src/test/java/cn/bunny/services/controller/LoginTest.java b/service/src/test/java/cn/bunny/services/controller/LoginTest.java new file mode 100644 index 0000000..ed8ea5e --- /dev/null +++ b/service/src/test/java/cn/bunny/services/controller/LoginTest.java @@ -0,0 +1,37 @@ +package cn.bunny.services.controller; + +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.openqa.selenium.chrome.ChromeDriver; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; + +import java.time.Duration; +import java.util.concurrent.TimeUnit; + +@SpringBootTest +@AutoConfigureMockMvc +public class LoginTest { + private ChromeDriver chromeDriver; + + @BeforeEach + void setUpMockMvc() { + chromeDriver = new ChromeDriver(); + } + + @AfterEach + void tearDown() { + chromeDriver.quit(); + } + + // 测试登录页面 + @Test + // @WithMockUser(username = "Administrator", password = "admin123", roles = "admin") + // @WithUserDetails("Administrator") + void testLogin() throws InterruptedException { + chromeDriver.get("http://localhost:7000/"); + TimeUnit.MINUTES.sleep(100); + chromeDriver.manage().timeouts().implicitlyWait(Duration.of(1000L, TimeUnit.SECONDS.toChronoUnit())); + } +}