square-oxygen-75288
01/14/2021, 10:05 AM11:01:39 00:12 [run]
Auto-detected 32 processors, using -parallel-threads=32
.E.E.E.E
Time: 0.021
There were 4 failures:
1) initializationError
java.lang.NullPointerException
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ScalaTestUtil.getJUnitRunner(ScalaTestUtil.java:62)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.CustomAnnotationBuilder$ScalaTestAnnotatedBuilder.runnerForClass(CustomAnnotationBuilder.java:52)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.AnnotatedClassRequest.getRunner(AnnotatedClassRequest.java:41)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.CompositeRequestRunner.runChild(CompositeRequestRunner.java:53)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConcurrentCompositeRequestRunner$1$1.run(ConcurrentCompositeRequestRunner.java:37)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConcurrentRunnerScheduler.finished(ConcurrentRunnerScheduler.java:89)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConcurrentCompositeRequestRunner$1.evaluate(ConcurrentCompositeRequestRunner.java:46)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConsoleRunnerImpl.runLegacy(ConsoleRunnerImpl.java:613)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConsoleRunnerImpl.run(ConsoleRunnerImpl.java:503)
at __shaded_by_pants__.org.pantsbuild.tools.junit.impl.ConsoleRunnerImpl.main(ConsoleRunnerImpl.java:790)
is it something that just needs some additional configuration which we are missing currently?enough-analyst-54434
01/14/2021, 12:13 PMloud-stone-83419
01/14/2021, 1:05 PMsquare-oxygen-75288
01/14/2021, 1:09 PMextend FlatSpec
everywhere. No annotations.
Test targets look something like
junit_tests(
name='foo',
sources=['./foo/*.scala'],
dependencies=[
':specs'
]
)
loud-stone-83419
01/14/2021, 1:10 PMsquare-oxygen-75288
01/14/2021, 1:13 PMjar_library(name='scalatest',
jars=[
scala_jar(org='org.scalatest', name='scalatest', rev='3.2.0')
])
jar_library(name='scalacheck',
jars=[
scala_jar(org='org.scalatestplus', name='scalacheck-1-14', rev='3.2.0.0'),
scala_jar(org='com.github.alexarchambault', name='scalacheck-shapeless_1.14', rev='1.2.0')
])
prior was
jar_library(name='scalatest',
jars=[
scala_jar(org='org.scalatest', name='scalatest', rev='3.0.8')
])
jar_library(name='scalacheck',
jars=[
scala_jar(org='org.scalacheck', name='scalacheck', rev='1.14.0'),
scala_jar(org='com.github.alexarchambault', name='scalacheck-shapeless_1.14', rev='1.2.0')
])
we have a target to bring it all together
target(
name='specs',
dependencies=[
'3rdparty:scalatest',
'3rdparty:scalamock',
]
)
and the junit target is
junit_tests(
name='foo',
sources=['./foo/*.scala'],
dependencies=[
':specs'
]
)
enough-analyst-54434
01/14/2021, 1:31 PMorg.scalatestplus.junit.JUnitRunner
could not be loaded: https://github.com/pantsbuild/pants/blob/a7b1a5ab1800ecac561a5c3b5ff2be7b9f58a2c0/src/java/org/pantsbuild/tools/junit/impl/ScalaTestUtil.java#L[…]20
And so you probably need to add a direct dependency on scalatestplus-junit. I can only find this one: https://search.maven.org/artifact/org.scalatestplus/junit-4-13_3.0.0-M3/3.2.3.0/bundle but I'm not sure if that's the right version to try.square-oxygen-75288
01/14/2021, 1:35 PMjar_library(name='scalatest',
jars=[
scala_jar(org='org.scalatest', name='scalatest', rev='3.2.3'),
scala_jar(org='org.scalatestplus', name='scalacheck-1-15', rev='3.2.3.0'),
scala_jar(org='org.scalatestplus', name='junit-4-13', rev='3.2.3.0')
])
it did not helpenough-analyst-54434
01/14/2021, 1:40 PM$ coursier fetch org.scalatestplus:junit-4-13_3.0.0-M3:3.2.3.0
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalatestplus/junit-4-13_3.0.0-M3/3.2.3.0/junit-4-13_3.0.0-M3-3.2.3.0.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3.0.0-M3/3.0.0-M3/scala3-library_3.0.0-M3-3.0.0-M3.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalatest/scalatest-core_3.0.0-M3/3.2.3/scalatest-core_3.0.0-M3-3.2.3.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/junit/junit/4.13/junit-4.13.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.4/scala-library-2.13.4.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalactic/scalactic_3.0.0-M3/3.2.3/scalactic_3.0.0-M3-3.2.3.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalatest/scalatest-compatible/3.2.3/scalatest-compatible-3.2.3.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/modules/scala-xml_2.13/1.2.0/scala-xml_2.13-1.2.0.jar
/home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar
$ zipinfo -1 /home/jsirois/.cache/coursier/v1/https/repo1.maven.org/maven2/org/scalatestplus/junit-4-13_3.0.0-M3/3.2.3.0/junit-4-13_3.0.0-M3-3.2.3.0.jar | grep JUnitRunner
org/scalatestplus/junit/JUnitRunner.class
org/scalatestplus/junit/JUnitRunner.tasty
org.scalatestplus:junit-4-13_3.0.0-M3:3.2.3.0
- Are you in fact using scala 3.0.0-M3? That's the only scalatestplus-junit artifact I can find on maven central.square-oxygen-75288
01/14/2021, 1:50 PMenough-analyst-54434
01/14/2021, 1:53 PMorg.scalatestplus:junit-4-12_2.12:3.2.0.0
with coursier, so you probably need: scala_jar(org='org.scalatestplus', name='junit-4-12', rev='3.2.0.0')
square-oxygen-75288
01/14/2021, 1:55 PMloud-stone-83419
01/14/2021, 2:01 PMsquare-oxygen-75288
01/14/2021, 2:14 PMorg.scalatestplus.junit.JUnitRunner
cannot be loaded (and a NPE is thrown)... it is available in the classpath, as I can add the annotation like
@RunWith(classOf[JUnitRunner])
see it in my repo: https://github.com/slvrtrn/pants-1.30-junit-scalatest-issue/blob/main/test/scala/com/github/slvrtrn/TestHello.scala#L3-L20
but john.sirois provided the sources of failure
https://github.com/pantsbuild/pants/blob/a7b1a5ab1800ecac561a5c3b5ff2be7b9f58a2c0/src/java/org/pantsbuild/tools/junit/impl/ScalaTestUtil.java#L[…]63
and
https://github.com/pantsbuild/pants/blob/a7b1a5ab1800ecac561a5c3b5ff2be7b9f58a2c0/src/java/org/pantsbuild/tools/junit/impl/ScalaTestUtil.java#L[…]20
in the latter,
junitRunnerClass = Class.forName("org.scalatestplus.junit.JUnitRunner");
seems to be the correct one!
so what is the problem then?..enough-analyst-54434
01/14/2021, 2:23 PMjunit
BUILD.tools so that Pant's junit-runner tool can still see the scalatestplus class after shading.square-oxygen-75288
01/14/2021, 2:25 PM