ses
ses

Reputation: 13342

checking constructor arguments in mockito' verify method

How to check that compareTo method will be invoked with this argument new ComparableVersion("1"))

  verify(comparableVersion).compareTo(any(ComparableVersion.class));

Now I use any - this is not enough.

Upvotes: 1

Views: 477

Answers (1)

NilsH
NilsH

Reputation: 13821

If you implement a proper equals method in your class, you can use the eq matcher. It will not verify your constructor, but it will verify against an object that has been initialized to a known state.

Upvotes: 1

Related Questions