Search code examples
mavenscalatest

Maven not discovering Scala tests


I am new to maven and trying to make it work with ScalaTest. In my pom.xml, I disabled sunfire and enabled the maven scala test plugin. (As in the link below)

I also put the tags for sourceDirectory and testSourceDirectory

    <sourceDirectory>src/main/scala</sourceDirectory>
    <testSourceDirectory>src/test/scala</testSourceDirectory>

Here are my folders:

src
 - main
   - scala
     - lot.of.packages
       - utility
         * ClassName
 - test
   - scala
     - lot.of.packages
       - utility
         * ClassNameTest

I am trying to run the tests with mvn test

The problem is that Maven does not discover the tests.

Discovery starting.
Discovery completed in 272 milliseconds.
Run starting. Expected test count is: 0

The strangest thing is if I run manually the test in the ide (Intellij), then it does discover the test with mvn after.

But if I add a new test, once again it does not discover the new test (might be a cache problem?)

I already looked there, but I did not find any answer Maven not discovering ScalaTest unit tests

If there is any information missing, comment below I will add them

Thanks


Solution

  • In the net.alchim31.maven:scala-maven-plugin:3.1.6 plugin, adding <goal>testCompile</goal>in the compile execution phase is a workaround, not the solution but good enough for the moment.