scala-cli icon indicating copy to clipboard operation
scala-cli copied to clipboard

Run specific test by `--only` option

Open tanishiking opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. In my project https://github.com/tanishiking/monkeys, there are multiple test files such as parser/Parser.test.scala and scanner/Scanner.test.scala. We can run all tests by scala-cli test ., however, we can't run a specific test. For example scala-cli test parser/Parser.test.scala doesn't compile because parser/Parser.test.scala depends on scanner/Scanner.scala.

Describe the solution you'd like It would be great if we can run only specified tests by scala-cli test . --only <FQN-of-test>

Describe alternatives you've considered Just run all tests by scala-cli test .

Additional context testOnly, test

tanishiking avatar Aug 01 '22 12:08 tanishiking

I am not sure about the naming of the --only flag, but we definitely should have some reasonable way of filtering tests. It will probably take time to fully support each of the major test frameworks, but we should be able to support most through JUnit.

TLDR; let's do a spike on this first.

Gedochao avatar Aug 04 '22 08:08 Gedochao

For reference: with the JUnit Interface it is already possible to run specific tests, just not a specific complete suite. For example, in the monkeys project from @tanishiking:

% scala-cli test . -- --tests=return-statement
==> i monkeys.parser.ParserTests.let-statement ignored 0.0s
monkeys.parser.ParserTests:
  + return-statement 0.02s
==> i monkeys.scanner.SnannerTests.basic ignored 0.0s
==> i monkeys.scanner.SnannerTests.advanced ignored 0.0s
monkeys.scanner.SnannerTests:

sander avatar Aug 10 '22 05:08 sander

For reference: with the JUnit Interface it is already possible to run specific tests, just not a specific complete suite.

Oh, huh, I didn't realise it was this easy, already. I suspect adding support for running a specific complete suite shouldn't be very hard, either. We'll see about some sort of smarter filtering of the tests as well, once this ticket is picked up.

Gedochao avatar Aug 12 '22 10:08 Gedochao

This has been done in https://github.com/VirtusLab/scala-cli/pull/1604, closing the ticket.

lwronski avatar Nov 30 '22 12:11 lwronski