1


I have following structure for my "tests" module written in scala

tests/
    build.gradle
    src/
         resources/
         scala/
             system/basic/SomeTests.scala

I can run all tests under scala folder using

./gradlew tests:test

How can I run only SomeTests.scala from command line?

Sandy
  • 2,253
  • 6
  • 24
  • 33
  • 1
    Possible duplicate of [How to run only one test class on gradle](https://stackoverflow.com/questions/22505533/how-to-run-only-one-test-class-on-gradle) – Gábor Bakos Dec 06 '17 at 13:46

1 Answers1

1

If it is not different to Java, then by using the --tests task parameter like

./gradlew tests:test --tests system.basic.SomeTests

to run all tests in that class, or e.g.

./gradlew tests:test --tests system.basic.SomeTests.foo

to only run the foo test method.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • it still ends up running all the tests looking like --tests param is not entertained at all – Sandy Dec 06 '17 at 14:54
  • Run with `-i` and / or `-d` to get more info on what is going on and add the output to your question – Vampire Dec 06 '17 at 20:21
  • 1
    hmm this doesnt work for Gradle 6.9. Command: `./gradlew tests:test --tests someProject.TestClass` gives: `Project 'tests' not found in root project 'someProject'.` – xhudik Jun 14 '21 at 09:29
  • Well, it seems you do not have a project called `tests` @xhudik. OP has such a project. ;-) – Vampire Apr 05 '23 at 17:29