使用maven进行测试设置断点调试的方法


在Maven中配置测试插件surefire来进行单元测试, 默认情况下,surefire会执行文件名以Test开头或结尾的测试用例,或者是以TestCase结尾的测试用例。
                   < plugin >
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <argLine>${surefireArgLine}</argLine>
                    <!--testng.xml -->
                    <suiteXmlFiles>
                        <suiteXmlFile>target/test-classes/testcase/testng.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <testFailureIgnore>true</testFailureIgnore>
<!--                     <debugForkedProcess>true</debugForkedProcess>  -->
                    <properties>
                        <property>
                            <name>usedefaultlisteners</name>
                            <value>false</value>
                        </property>
                    </properties>
                    <!--  target -->
                    <workingDirectory>target/</workingDirectory>
                </configuration>
            </plugin>  
按上述配置执行,maven test 会忽略程序中的断点执行,如果要进行调试可通过下面两个方法设置:
1、使用配置 testFailureIgnore  配置
在pom.xml文件中 < configuration >  结点下,增加 <debugForkedProcess>true</debugForkedProcess>
2、配置maven test参数
在Debug->Debug Config 设置框中,设置Goals值为:test -Dmaven.surefire.debug即可。


注意:在配置支持断点调试的模式下运行后,控制台console会出现“ Listening for transport dt_socket at address: 5005 ”,要单击一下才能继续运行。










免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM