1

I'm writing a new unit test and am getting a java.lang.Exception thrown with the error "no Mockery found in test class". This is happening as an initializationError which makes sense as I'm setting up the mocks in an @Before method.

Does anyone know what causes this error and what needs to be done to work around it?

Tim B
  • 40,716
  • 16
  • 83
  • 128

3 Answers3

1

In newer situations you might want to look into the property junit.jupiter.extensions.autodetection.enabled. JMock seems to have a challenge with respect to this. Read: https://github.com/jmock-developers/jmock-library/issues/155 No official fix available yet. But it helped me to fix things in my situation: I had to exclude the artifact quarkus-junit5-properties in my Quarkus project under dependency quarkus-junit5. This artifact caused the above setting to be set to true.

gkephorus
  • 1,232
  • 18
  • 31
0

I've found the solution. I had somehow copied in an:

@RunWith(JMockCategoryRunner.class)

annotation from another file and removing that got rid of the problem.

Tim B
  • 40,716
  • 16
  • 83
  • 128
-2

Do you have Mockery installed? If not, update your composer.json:

"require-dev": {
    "mockery/mockery": "dev-master@dev"
}

Then run:

composer update

answer from here

Community
  • 1
  • 1
Ryan
  • 1,972
  • 2
  • 23
  • 36