使用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