[英]Debugging maven tests with netbeans 6.9.1?
我在netbeans 6.9.1中有一個maven項目,在那里有一個junit 4.4測試類。
在netbeans上下文菜單中,我可以“清理並構建”我的項目,在輸出中我可以看到,我的測試類是通過surefire找到並運行的。
現在我從上下文菜單“調試測試文件”中選擇,在輸出中就好了
--- maven-compiler-plugin:2.3.2:testCompile(default-testCompile)@ <project-name> ---將2個源文件編譯為<project-path> \\ target \\ test-classes
--- maven-surefire-plugin:2.7.2:test(default-cli)@ <project-name> --- Surefire報告目錄:<project-path> \\ target \\ surefire-reports
試驗
沒有測試可以運行。
到目前為止我檢查了什么:
構建項目找到測試文件,但是<testSourceDirectory>是正確的
只有一個junit - 4.4 in * .pom依賴項
類文件本身看起來像
import junit.framework.TestCase;
import org.junit.Test;
公共類SomeTest擴展TestCase {@Test public void testFoo()拋出異常{/ --- /}}
調試的netbeans動作描述看起來像
執行目標:test-compile surefire:test
設置屬性:jpda.listen = true maven.surefire.debug = -Xdebug -Xrunjdwp:transport = dt_socket,server = n,address = $ {jpda.address} jpda.stopclass = $ {packageClassName} failIfNoTests = false //這是我的補充,沒有它仍然失敗forkMode =一次test = $ {className}
項目* .pom文件中的任何地方都沒有surefire插件部分
這不是一個netbeans問題。
您已經定義了JUnit 3測試,但是您嘗試使用JUnit 4運行器來運行它們。 Surefire使用以下規則來確定使用哪個跑步者(來自maven-surefire-plugin Junit )
if the JUnit version in the project >= 4.7 and the parallel attribute has ANY value
use junit47 provider
if JUnit >= 4.0 is present
use junit4 provider
else
use junit3.8.1
你的項目中有junit 4.4,所以它使用的是junit4。 由於您只有2個測試類,因此最好的選擇是將測試重新定義為JUnit 4測試。 刪除擴展的TestCase,在測試注釋之后添加@ Test / @ Before / @,並完全刪除JUnit 3的東西。
有關執行遷移的更多信息,請參閱將測試從JUnit 3自動遷移到JUnit 4的最佳方法?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.