我正在尝试运行以下自动测试:
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
class MyControllerTest {
@LocalServerPort
int port;
@Autowired
TestRestTemplate rest;
private String myUrl() {
return String.format("http://localhost:%d/...", port);
}
@Test
public void testMyUrl() {
String response = rest.getForObject(myUrl(), String.class);
System.out.println("");
}
}
我正在IntelliJ Idea调试器下运行它,我可以跟踪
testMyUrl
作用不幸的是,控制器代码中的任何断点都会被忽略。这可能是因为它是在独立的进程中执行的,调试器并没有附加到该进程。
问题是:是否有可能自动化或轻松地附加到这个过程中?我在
Quarkus
使用Quarkus插件。Spring也可以这样做吗?