Native library for Attach API not available in this JRE

java.util.ServiceConfigurationError: org.testng.ITestNGListener: Provider mockit.integration.testng.Initializer could not be instantiated: java.lang.IllegalStateException: Native library for Attach API not available in this JRE
at java.util.ServiceLoader.fail(Unknown Source)


解决方法:

在eclipse->run->run configurations->TestNG选择所运行的测试类,在Arguments下的VM Arguments下加上
-javaagent:C:\jmockit-1.13后便可正常运行test case了。


如果还报错,请往下看:
可能是由于环境配置的是JRE而不是JDK,JMock正常运行需要配置JDK,方法如下:
Eclipse-->Window-->Preferences-->Java-->Installed JREs
点击“Add”,添加JDK:

继续

选中测试类,鼠标右键-->run Configuration 点击“jar”选项,Alternate JAR 选择jdk,不要选择jar,然后Apply 。。。 Run ,应该就可以了。

猜你喜欢

转载自sunningqu.iteye.com/blog/2204194
今日推荐