I had issue when running test with some unusual project structure. For example you have 3 projects A, B, C. C depends on A and B. A and C has set buildDir, and B - hasn’t. On executing test for C which contains references to classes from A and B - I got exception java.lang.NoClassDefFoundError, but the compile works ok, and A\B tests as well. The jar for B and C during test C placed to build dir of project C, jar for B placed to build dir for B, but seems not included to classpath.
As workaround - define buildDir for A - test task executed without problems.
Sorry, can’t upload test project (as I new user), any help to upload test build is appreciated :). link to shared example on google drive test build