NoClassDefFoundError when using Powermock

前端 未结 5 1275
栀梦
栀梦 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:30

    I just solved this one now, when I added the @RunWith(PowerMockRunner.class) attribute, eclipse automatically imported:

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

    All I needed to do is change it to be:

    import org.powermock.modules.junit4.PowerMockRunner;
    

    And now it works fine with JUnit 4.8.2.

    The 2nd runner is for when running with older versions of JUnit - specifically 4.3 and older.

提交回复
热议问题