NoClassDefFoundError when using Powermock

前端 未结 5 1265
栀梦
栀梦 2020-12-09 01:24

I\'m running a junit test case using the PowerMock test runner. I\'m using the following command line to execute it:

java -cp .:jun         


        
5条回答
  •  失恋的感觉
    2020-12-09 02:22

    This Exception occurs when you Import the legacy version of PowerMockRunner.class when using JUnit 4.X or higher version since this legacy class is not available to run when using it with @RunWith annotation. I have solved this issue by replacing older legacy version import with the new version.

    Incorrect Import:

    import org.powermock.modules.junit4.legacy.PowerMockRunner;
    

    Correct Import:

    import org.powermock.modules.junit4.PowerMockRunner;
    

提交回复
热议问题