TestNG + Spring + Power mock Unit test -
i have spring based application , in process of unit testing it. i'm using testng unit tests. test need make use of powermockito mock static methods. need make use of test spring config file unit test.
i'm unable write unit tests combining 3 i.e. testng, powermock , spring.
i can combine testng , spring extending class abstracttestngspringcontexttests, cant mock static methods, instead executes actual static method. below:
@preparefortest(myutils.class) @contextconfiguration(locations = { "classpath:config/test-context.xml"}) public class myimpltest extends abstracttestngspringcontexttests{ ..... } i can combine testng powermockito extending class powermocktestcase. test spring config files not resolved. below:
@preparefortest(myutils.class) @contextconfiguration(locations = { "classpath:config/test-context.xml"}) public class myimpltest extends powermocktestcase{ ..... } is there way me write unit tests combining three, i.e. testng, powermockito , spring context?
rather extending powermocktestcase, have tried using powermockobjectfactory writing method below? can extend abstracttestngspringcontexttests.
@objectfactory public iobjectfactory getobjectfactory() { return new org.powermock.modules.testng.powermockobjectfactory(); }
this suggested powermock github docs.
Comments
Post a Comment