<dependency> <groupId>org.eclipse.jetty</groupId> <artifactId>jetty-test-junit5</artifactId> <version>...</version> </dependency> import org.eclipse.jetty.server.Server; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MyWebAppTest { private Server server; @BeforeEach public void setup() throws Exception { server = JettyTestServer.start(MyWebApp.class, "/"); } @AfterEach public void teardown() throws Exception { JettyTestServer.stop(server); } @Test public void testHomePage() throws Exception { String response = HttpUtils.get("http://localhost:8080/"); Assertions.assertEquals("Hello, World!", response); } }


上一篇:
下一篇:
切换中文