John Smith
John Smith

Reputation: 874

Invalid place to record Expectations

I'm using JMockit 1.14 with Junit 4.

private void method()
{
    new NonStrictExpectations()
    {
        {
            firstObject.getLock();
            returns(new Lock());

            secondObject.getDetails();
            result = secondObjectDetails;

            secondObject.isAvailable();
            result = true;
        }
    };
}

Is there anything obviously wrong with my code?

Upvotes: 2

Views: 4220

Answers (1)

Lenny Thompson
Lenny Thompson

Reputation: 57

I resolved a similar issue (using android studio, junit 4.12 and JMockit 1.20) by adding

@RunWith(JMockit.class)

outside the test case class, with a couple of import changes.

See JMockit documentation: http://jmockit.org/tutorial/Introduction.html#runningTests

Upvotes: 2

Related Questions