Reputation: 607
I have a problem about running PowerMock with @Runwith(Enclosed.class) in pararell.
My test class structure:
@RunWith(PowerMockRunner.class)
@PrepareForTest(UnitBuild.class)
public class ut_QueueBuild{
@Test
public void someTest(){}
public static InnerTestClass{
@Test
public void someInnerTest(){}
}
}
Before using powerMock I just used:
@RunWith(Enclosed.class)
public class unitTestClass {
...
But since I am using PowerMock there is no possibility to use in pararell @Runwith(PowerMockRunner.class) and @Runwith(Enclosed.class)
How can I solve this ?
Thanks a lot !
Upvotes: 1
Views: 1135
Reputation: 17713
Actually you can use PowerMockRunnerDelegate
and do:
@RunWith(PowerMockRunner.class)
@PowerMockRunnerDelegate(Enclosed.class)
@PrepareForTest(MyStaticClass.class)
public class ut_QueueBuild{
@Test
public void someTest(){}
public static InnerTestClass{
@Test
public void someInnerTest(){}
}
}
This applies also to other runners, like the Parametrized
.
Upvotes: 1
Reputation: 4973
JUnit4 only supports one @RunWith annotation, and JUnit4's @RunWith annotation doesn’t accept multiple runners.Reference: project13
Possible duplicate question but here's the answer from this StackOverflow Question @Matthew Farwell
No, you either need to:
use one and create a test base class that does the things you wanted the other runner to do. separate your test into multiple tests, each using different runners.
Upvotes: 0