I am trying to build a SBT project which will encompass both unit and end-to-end tests, and will support tests being written in both Scala (extending standard Scalatest
suites, e.g. AnyFlatSpec
) and Java (extending org.scalatestplus.testng.TestNGSuite
).
In order to avoid running end-to-end tests in the normal course of things, I have a tag annotation E2ETest
. Scalatest provides invocation arguments for including/excluding suites (and individual tests, but that’s not relevant to this question) based on tag annotations.
Unfortunately, while this annotation scheme works just fine for Scala test classes, it doesn’t appear to be respected for Java test classes:
// scala
@E2ETest
class ServiceE2ESpec extends AnyFlatSpecLike {
// test code goes here
}
is skipped when -l E2ETest
is passed to the test
invocation, but
// java
@E2ETest
public class ServiceE2ETest extends TEstNGSuite {
// test methods go here
}
is not skipped.
See full MWE here
Am I using these annotations (or the Scalatest invocations) wrong somehow, or is this a bug in Scalatest (or the testng
bridge library, or in sbt
itself)?