scalatest-junit-runner icon indicating copy to clipboard operation
scalatest-junit-runner copied to clipboard

Test discovery breaks when running into classes/objects which are not valid Tests

Open rayalex opened this issue 1 year ago • 1 comments

Describe the bug When adding utility classes/objects to test source sets, the plugin tries to scan them for tests but fails with:

class co.helmethair.scalatest.runtime.Discovery cannot access a member of class ***SomeHelper$ with modifiers "private"

To Reproduce

object SomeHelper extends MockFactory {
  def something(...)
}

placed under src/test/scala/{package} causes the above to be recognized as the test and fail.

Expected behavior Such classes should be ignored.

Screenshots N/A

Build/Test environment:

  • Gradle 7
  • Scala 2.12
  • Scalatest 3.2.15

Thanks!

rayalex avatar Mar 07 '23 13:03 rayalex

Thank you for the report!

I checked the issue, was able to reproduce. It seems to me, that MockFactory inherits from TestSuite and this confuses the discovery as it thinks the class is a test suite which needs to be executed. In the following examples I see the MockFactory used differently: https://www.javadoc.io/static/org.scalamock/scalamock_2.12/3.4.1/org/scalamock/scalatest/MockFactory.html The above use-case does not cause problems, it might be a workaround for you until I fix this bug.

giurim avatar Apr 27 '23 09:04 giurim