使用Eclipse写Mockito单元测试的问题
最近在Maven项目中,使用Mockito+Junit写单元测试的时候,遇到一些问题,一运行单元测试,就报错:
java.lang.VerifyError: Bad <init> method call from inside of a branch
Exception Details:
Location:
com/netease/epay/boss/customer/order/OrderQueryServiceTest.<init>()V @34: invokespecial
Reason:
Error exists in the bytecode
Bytecode:
0000000: 2a4c 1300 18b8 001e 03bd 000f 1300 1fb8
0000010: 0023 b800 294e 2db2 002d a500 0e2a 01c0
0000020: 002f b700 32a7 0009 2bb7 0034 0157 2a00
0000030: 0000 0001 4c01 4d13 0036 b800 3903 bd00
0000040: 0f13 003b b800 23b8 003e 4e2d b200 2da5
0000050: 0030 2dc1 0040 9900 21b8 0046 1300 36b8
...
解决办法:
windows->preferences
这里增加默认的VM参数配置:-XX:-UseSplitVerifier
原因,JDK版本不一致导致报错。