Question

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. 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

<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.

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?

Was it helpful?

Solution

Can't you use the @RunWith annotation provided by jUnit?

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

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
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top