Closed. This question is off-topic。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗? Update the question,所以它是on-topic,用于堆栈溢出。
                        
                        3年前关闭。
                                                                                            
                
        
我们已经移至Java 1.7,现在不推荐使用Jmock.class。有其他选择吗?网站似乎已被废弃...

最佳答案

您可能需要JUnitRuleMockery规则。

public class TestSomething {
    @Rule
    public final JUnitRuleMockery context = new JUnitRuleMockery();

    @Mock
    private MyInterface interface;

    @Test
    public void testTheThing() {
        context.checking(new Expectations{{

         }});
        // etc.
    }


您将需要在类路径上使用jmock-junit4依赖项...

        <dependency>
            <groupId>org.jmock</groupId>
            <artifactId>jmock-junit4</artifactId>
            <version>2.8.1</version>
            <scope>test</scope>
        </dependency>

10-07 13:55