I know how to mock static methods from a class using PowerMock.
But I want to mock static methods from multiple classes in a test class using JUnit and PowerMock.
Can anyone tell me is it possible to do this and how to do it?
I know how to mock static methods from a class using PowerMock.
But I want to mock static methods from multiple classes in a test class using JUnit and PowerMock.
Can anyone tell me is it possible to do this and how to do it?
In java with powermock/junit, use @PrepareForTest({}) with as many static classes as you want as array ({}).
@RunWith(PowerMockRunner.class)
@PrepareForTest({XmlConverterA.class, XmlConverterB.class})
class TransfersServiceExceptionSpec {
}
I have used powermock with in scala/junit, as scalatest does not have integration with powermock.
@RunWith(classOf[PowerMockRunner])
@PrepareForTest(Array(classOf[XmlConverterA], classOf[XmlConverterB]))
class TransfersServiceExceptionSpec {
@Test
def test() {
}
}