Skip to content

Verifications not working with TestNG 6.11 #463

@marek-krajewski

Description

@marek-krajewski
  • JMockit: 1.35
  • TestNG: 6.11

Verifications block throws in the following code:

public class Test {
    public interface Dependency {
        void call();
    }
    
    static class TestedClass {
        public void testedMethod(Dependency dependency) {
            dependency.call();
        }
    }

    @org.testng.annotations.Test
    public void test(@Injectable Dependency dependency) {
        TestedClass tested = new TestedClass();
        tested.testedMethod(dependency);

        new Verifications() {{
            dependency.call(); times = 1; // throws: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        }};
    }
}

Exception is thrown by the UnorderedVerificationPhase.handleInvocationCountConstraint(...) Line: 88, because the expectationsInReplayOrder is empty. Problem occurs only when the interface is public (also when located in different file) and only when Dependency is mocked as the parameter of the test method. Mocking a class in a similar manners works.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions