@RunWith(Parameterized.class)
@PrepareForTest(Helper.class)
public class ParameterizedPowerMock {
/**
* @RunWith(PowerMockRunner.class)
*
* The Main thing to look out for Here is the
* Parameterized Version of Powermock & @Rule
* i.e. PowerMockRule.
*
* For JUnit Parameterized Test cases the class
* needs to be annotated with @RunWith(Parameterized.class)
* and for Powermock the class needs to be annotated with
* @RunWith(PowerMockRunner.class), so a Test class at the same
* Time cannot be annotated with both @Runwith classes,
* So we are using here @Rule
*
* Two important points to be kept in mind for JUnit 4 Parameterized
* Test cases with PoweMock is that, and Rule and Test Class Constructor
* should be public
*
*/
//@Rule should be declared Public
public @Rule PowerMockRule rule = new PowerMockRule();
String param;
String expectedResult;
//The constructor should be declared Public
public ParameterizedPowerMock(String param, String expectedResult)
{
this.param = param;
this.expectedResult = expectedResult;
}
@Parameterized.Parameters
public static Iterable
Sunday, 22 March 2015
Parameterized Mocking with Powermock
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment