jmockit / jmockit1

Advanced Java library for integration testing, mocking, faking, and code coverage
Other
465 stars 240 forks source link

VerificationsInOrder not work ? #165

Closed udrnrso closed 9 years ago

udrnrso commented 9 years ago

I think the test below shoud failed, but actually success . Is it a bug ?

public class DependencyTest { class Dependency { public void start() {

    }
    public void doSomthine() {

    }
    public void end(){

    }
}

@Mocked Dependency depency;

@Test 
public void test_WrongOrder_ShouldFailed() {
    depency.start();
    depency.end();
    depency.doSomthine();
    depency.doSomthine();

    new VerificationsInOrder() {
        {
            depency.start();times= 1;
            depency.doSomthine();minTimes = 1;
            depency.end();times=1;
        }
    };
}

}

rliesenfeld commented 9 years ago

It is failing when I run it, with the following failure:

Running DependencyTest Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.187 sec <<< FAILURE! - in DependencyTest test_WrongOrder_ShouldFailed(DependencyTest) Time elapsed: 0.047 sec <<< ERROR! mockit.internal.MissingInvocation: Missing invocation of: DependencyTest$Dependency#end() on mock instance: DependencyTest$Dependency@66e8791 at DependencyTest$Dependency.end(DependencyTest.java) at DependencyTest$1.(DependencyTest.java:24) at DependencyTest.test_WrongOrder_ShouldFailed(DependencyTest.java:20)

Which versions of JMockit and JUnit/TestNG did you use?

udrnrso commented 9 years ago

My JMockit is 0.999.4 and Junit is 4.12, could it be old version issue?could it be old version issue?

rliesenfeld commented 9 years ago

Yes, it must be the old version.