如何在IntelliJ中调试集成测试? [英] How to debug integration test in IntelliJ?

查看:61
本文介绍了如何在IntelliJ中调试集成测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在 Maven Projects 中为

mvn -Dit.test=PredictionWorkflowTest verify

看起来像这里

,然后在 PredictionWorkflowTest 中设置断点.不幸的是,当我右键单击此配置并选择对其进行调试时,测试通过,就好像没有设置断点一样.

and then set breakpoint inside PredictionWorkflowTest. Unfortunately, when I right click this configuration and select to debug it, tests passes as if no breakpoint were set.

如何使断点起作用?

如果我通过单击类本身进行测试,则会触发断点,但集成条件不起作用(服务器未启动).

If I run test by clicking class itself, then breakpoints trigger, but integration conditions don't me (servers not starting).

推荐答案

步骤1:将调试添加到Maven运行配置

您可能正在使用Maven故障安全插件来运行测试,如其文档

You are probably using Maven Failsafe Plugin to run the tests as explained in their documentation

如果是这种情况,则需要添加 -Dmaven.failsafe.debug (

If that's the case you need to add -Dmaven.failsafe.debug (documentation here) to your maven configuration so it becomes

mvn -Dit.test = PredictionWorkflowTest验证-Dmaven.failsafe.debug .

运行此maven命令时,默认情况下,调试器将在端口5005侦听

When you run this maven command, the debugger will be listening at port 5005 by default

步骤2:在IntelliJ中配置远程调试器

现在,在IntelliJ中,您需要在 localhost 和端口 5005

Now in IntelliJ you need to configure a remote debugger configuration on localhost and port 5005

用于集成测试的远程调试器配置

第3步:调试您的应用

最后,运行maven命令.在测试之前,它将停止并等待调试器开始运行测试.以下消息将显示在终端中

Finally, run the maven command. Just before testing it will stop and wait for the debugger to start running the tests. The following message will be displayed in the terminal

侦听地址为5005的运输dt_socket

然后启动在步骤2中配置的远程调试器.这应该允许您在集成测试断点上调试应用程序.

Then start remote debugger configured in step 2. This should allow you to debug your app on integration tests break-points.

这篇关于如何在IntelliJ中调试集成测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆