我在我的项目中将 MRUnit 版本升级到 1.1.0,以使用 ReduceDriver 来测试多个输出。对我的测试进行更改(使其与升级一起使用)后,我收到此错误:
java.lang.VerifyError: Expecting a stackmap frame at branch target 63
Exception Details:
Location: (path to test class)
Reason: Expected stackmap frame at this location.
Bytecode: (Bytecode)
我的测试看起来像这样(特意删除了代码以使其更简洁):
@RunWith(PowerMockRunner.class)
@PrepareForTest(MultipleOutputs.class)
public class myReducerTest {
private ReduceDriver<Text, Text, Text, Text> reduceDriver;
@Before
public void setUp() {
reduceDriver = ReduceDriver.newReduceDriver(new myReducer());
}
@Test
public void testHappyPath() throws IOException {
/*
Code to declare input key, inout value, expected output, etc.
*/
reduceDriver.withInput(myInputKey, myInputVal);
reduceDriver.withMultiOutput("reportName1", key, expectedValue1);
reduceDriver.withMultiOutput("reportName2", key, expectedValue2);
reduceDriver.runTest();
}
}
使用@PrepareForTest 时出现错误。请注意,myReducer类没有静态或最终方法。这就是为什么它不包含在 @PrepareForTest 注释中的原因。我的 pom 文件的一部分(我正在使用 maven 进行构建)如下所示:
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.mrunit</groupId>
<artifactId>mrunit</artifactId>
<version>1.1.0</version>
<classifier>hadoop2</classifier>
<scope>test</scope>
</dependency>
另请注意,我使用的是 Java 8,并且无法降级到 v7 或 v6,如此处所述:java.lang.VerifyError: Expecting a stackmap frame at branch target
我还尝试在 pom 文件中添加surefire插件,如此处所述: java.lang.VerifyError: Expecting a stackmap frame at branch target 73
在这种情况下,这些解决方案都不起作用。