[英]Maven: How can I run/include a class in a jar with the failsafe plugin?
I've made my own class with an @RunWith(AllTests.class)
on it for integration tests that I want to execute, but I've put it in a reusable jar. 我使用@RunWith(AllTests.class)
在我自己的类上进行了要执行的集成测试,但是我将其放在了可重用的jar中。 I'm trying to tell failsafe to use it but I'm not sure how to because the documentation for includes says: 我试图告诉故障保险使用它,但是我不确定该如何使用,因为包含的文档中说:
A list of elements specifying the tests (by pattern) that should be included in testing. 指定测试中应包括的测试(按模式)的元素列表。 When not specified and when the test parameter is not specified, the default includes will be 当未指定且未指定test参数时,默认包括
<includes> <include>**/IT*.java</include> <include>**/*IT.java</include> <include>**/*ITCase.java</include> </includes>
Each include item may also contain a comma-separated sublist of items, which will be treated as multiple entries. 每个包含项还可能包含项的逗号分隔子列表,这些子列表将被视为多个条目。 This parameter is ignored if the TestNG suiteXmlFiles parameter is specified. 如果指定了TestNG suiteXmlFiles参数,则忽略此参数。
But this test runner is in the classpath, not on the filesystem. 但是此测试运行程序位于类路径中,而不位于文件系统中。 How can I tell failsafe to use my class runner and only my class runner? 如何告诉故障保险仅使用班级跑步者?
Can't you use the @RunWith annotation provided by jUnit? 您不能使用jUnit提供的@RunWith注释吗?
import com.example.YourTestRunner;
@RunWith(YourTestRunner.class)
public class SomeIntegrationTest {
@Test
public void simpleTest() {
// given, when, then
}
}
Update 更新
Based on the comment: 根据评论:
My class isn't a test runner, but a class that uses @RunWith 我的课程不是测试跑步者,而是使用@RunWith的课程
you can use inheritance to solve the problem: 您可以使用继承来解决问题:
@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.