VirtusLab / scala-cli

Scala CLI is a command-line tool to interact with the Scala language. It lets you compile, run, test, and package your Scala code (and more!)
https://scala-cli.virtuslab.org
Apache License 2.0
551 stars 129 forks source link

Should pick up the correct test framework in mix testing frameworks project #1956

Open lenguyenthanh opened 1 year ago

lenguyenthanh commented 1 year ago

Version(s) Scala CLI version: 0.2.1 Scala version (default): 3.2.2

Describe the bug A test file with both munit and weaver and tests are written using weaver, scala-cli doesn't run any tests.

To Reproduce Example:

//> using lib "org.scalameta::munit:1.0.0-M7"
//> using lib "com.disneystreaming::weaver-cats:0.8.1"

import weaver._

object Test extends SimpleIOSuite {
  pureTest("foo"){
    expect(1 == 1)
  }
}

run scala-cli test . doesn't execute any test. Expected behaviour It should run pureTest test case. Addition information

If I specify test-framework then it works. Ex:

//> using lib "org.scalameta::munit:1.0.0-M7"
//> using lib "com.disneystreaming::weaver-cats:0.8.1"
//> using testFramework "weaver.framework.CatsEffect"

import weaver._

object Test extends SimpleIOSuite {
  pureTest("foo"){
    expect(1 == 1)
  }
}
lenguyenthanh commented 1 year ago

I think we can improve this by adding some line about weaver here: https://scala-cli.virtuslab.org/docs/commands/test#test-framework, with a note about specifying TestFramework if needed. I'll happy to make a PR for this.

The long term solution is making sure scala-cli picks up the correct one to execute in case of many test frameworks are in the class path. I can also dig into this a bit but not sure I can solve it.

Gedochao commented 1 year ago

I think we can improve this by adding some line about weaver here: https://scala-cli.virtuslab.org/docs/commands/test#test-framework, with a note about specifying TestFramework if needed. I'll happy to make a PR for this.

Yeah, such a PR would be much appreciated!

lenguyenthanh commented 1 year ago

thanks @Gedochao I'll create a pr for this soon!