簡體   English   中英

Maven:如何使用故障安全插件在jar中運行/包含類?

[英]Maven: How can I run/include a class in a jar with the failsafe plugin?

我使用@RunWith(AllTests.class)在我自己的類上進行了要執行的集成測試,但是我將其放在了可重用的jar中。 我試圖告訴故障保險使用它,但是我不確定該如何使用,因為包含的文檔中說:

指定測試中應包括的測試(按模式)的元素列表。 當未指定且未指定test參數時,默認包括

 <includes> <include>**/IT*.java</include> <include>**/*IT.java</include> <include>**/*ITCase.java</include> </includes> 

每個包含項還可能包含項的逗號分隔子列表,這些子列表將被視為多個條目。 如果指定了TestNG suiteXmlFiles參數,則忽略此參數。

但是此測試運行程序位於類路徑中,而不位於文件系統中。 如何告訴故障保險僅使用班級跑步者?

您不能使用jUnit提供的@RunWith注釋嗎?

import com.example.YourTestRunner;

@RunWith(YourTestRunner.class)
public class SomeIntegrationTest {

    @Test
    public void simpleTest() {
       // given, when, then
    }
}

更新

根據評論:

我的課程不是測試跑步者,而是使用@RunWith的課程

您可以使用繼承來解決問題:

@RunWith(SomeTestRunner.class)
@Ignore("Not a real test class because it does not contain any @Test methods, but needed to keep surefire happy")
public class ParentTest {
    // this is the reusable class that is in the jar file
}


public class SomeIntegrationTest extends ParentTest {

    @Test
    public void simpleTest() {
       // given, when, then
    }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM