0
以下TestNG的“为预期的记录无效的上下文中,”失败(6.3)测试情况下产生错误“无效上下文的期望的记录”TestNG的测试用例与JMockit
@Listeners({ Initializer.class })
public final class ClassUnderTestTest {
private ClassUnderTest cut;
@SuppressWarnings("unused")
@BeforeMethod
private void initialise() {
cut = new ClassUnderTest();
}
@Test
public void doSomething() {
new Expectations() {
MockedClass tmc;
{
tmc.doMethod("Hello"); result = "Hello";
}
};
String result = cut.doSomething();
assertEquals(result, "Hello");
}
}
被测试的班级如下。
public class ClassUnderTest {
MockedClass service = new MockedClass();
MockedInterface ifce = new MockedInterfaceImpl();
public String doSomething() {
return (String) service.doMethod("Hello");
}
public String doSomethingElse() {
return (String) ifce.testMethod("Hello again");
}
}
我在做,因为我现在用的是@Listeners注解,我不需要javaagent命令行参数的假设。这个假设可能是错误的......
任何人都可以指出我错过了什么?
谢谢,只是版本更新排序的问题。带你点关于听众。谢谢(你的)信息。 – sweetfa