bazelbuild / rules_scala

Scala rules for Bazel
Apache License 2.0
360 stars 273 forks source link

Support for specifying test classes and/or test cases when using junit tests #1512

Closed gergelyfabian closed 11 months ago

gergelyfabian commented 11 months ago

I have a test target that was defined with scala_junit_test. Is there any way to specify a test that I'd like to select to be run like I'd do for scalatest:

bazel test --test_arg=-s --test_arg=com.my.test.KlassTest --test_arg=-t "--test_arg=Klass should foo" -- //my/target:test
gergelyfabian commented 11 months ago

I guess this can be done with:

--test_filter=com.my.TestClassTest#
gergelyfabian commented 11 months ago

Selecting one test would be:

'--test_filter=com.my.TestClassTest#my test case'
srdo commented 11 months ago

As you say, I think rules_scala already supports this when running from the command line, so I'm not sure there's any need for changes on the rule end.

If you're using Intellij, I think this used to work from the IDE as well, and I accidentally broke it when adding support for specifying test cases for Scalatest to the IJ Bazel plugin.

There's a PR over here to fix it, I think it's very close to done and just needs a little polish. It's been quiet for a while, but if you feel like it, the author probably wouldn't mind you picking it up.

gergelyfabian commented 11 months ago

@srdo , thanks for the update on IntelliJ. Indeed it doesn't allow me running a single test case, I can only do that from the command line.