2

我在这里遵循示例:jMock - 入门

我收到此错误:无法解析类型 junit.framework.TestCase。它是从所需的 .class 文件中间接引用的

我已经导入了这 4 个罐子:

  • jmock-2.5.1.jar
  • hamcrest-core-1.1.jar
  • hamcrest-library-1.1.jar
  • jmock-junit3-2.5.1.jar

蚂蚁的想法这个错误是什么意思?

package com.test;

import org.jmock.integration.junit3.MockObjectTestCase;
import org.jmock.Expectations;

class PublisherTest extends MockObjectTestCase {
public void testOneSubscriberReceivesAMessage() {
    // set up
    final Subscriber subscriber = mock(Subscriber.class);

    Publisher publisher = new Publisher();
    publisher.add(subscriber);

    final String message = "message";

    // expectations
    checking(new Expectations() {
        {
            oneOf(subscriber).receive(message);
        }
    });

    // execute
    publisher.publish(message);
    }
}
4

1 回答 1

6

将 JUnit 3 添加到您的类路径中。

于 2012-04-18T23:18:04.353 回答