Menu
  • HOME
  • TAGS

scalamock: Wildcard argument match on subtype

scala,jmock,scalamock

First of all: The following does not compile, since the type ascription is only to help (static) overloading resolution. The line has nothing specific to Scalamock: (mock.method(_: SubTypedException)) To test the runtime type of the argument you can use ArgThat which was introduced in ScalaMock 3.2.1 together with a helper...

Unit test private inner class methods

java,unit-testing,mockito,jmock

since the cache need not be visible to external consumers A unit test is an external consumer. It's a class which invokes functionality on the object being tested, just like any other class. Caveat: There is much opinion and debate on this matter. What I'm presenting here isn't "the...

jMock - allowing() a call multiple times with different results

java,jmock

I would recommend taking a look at states - they allow you to change which expectation to use based on what "state" the test is in. @Auto private States clockState; @Test public void example() { clockState.startsAs("first"); timeNow(100); // do something clockState.become("second"); timeNow(105); // do something else } private void timeNow(final...

java.lang.VerifyError with Mockito 1.10.17

java,testng,mockito,jmock

The problem here is an unfortunate constellation between TestNG, JUnit and Mockto. To fix your issue, you just need to add a dependency to JUnit 4.0 or greater (the most recent version is currently 4.12): <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> </dependency> Here are the details: TestNG, which is apparently your testing...

JMock - Get reference to mocked method parameter

java,unit-testing,mocking,jmock

You can access the method's input via a custom matcher, but it carries with it a bad smell as you would be manipulating the structure inside the matcher which is not its purpose. A better route would be to change the design of the method to return the list so...