Ignoring Maven / Scala unit test files

I am writing my unit test scripts for a Java project using Scala (JUnit 4). I run tests using Maven.

I wrote a class src/test/scala/com.xxx.BaseTestfor tests to provide some common functions ( @BeforeClassetc.), but there are no real cases @Test.

Whenever I run tests using mvnthe command line, he insists on trying to find tests in the class BaseTestand gets an error because they are not there.

Besides usage @Ignore, is there a way to get Maven / Scala / Surefire not to try to run the class BaseTest? Adding is @Ignorenot a big deal, but my test run shows another test than what I actually have with the word “Missed: 1”.

The UPDATE . I have found a solution. I renamed BaseTestto Base; Maven is now ignoring this. Is there another way?

+3
source share
1 answer

You can either rename the base test class to not end * Test, for example BaseTestCase.java. This is what I would recommend.

Most likely maven runs tests with the surefire plugin , so you can simply configure the surefire plugin to skip BaseTest.java. I think by default, surefire assumes that all classes ending in *Testare test classes. Something like this in pom.xml.

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <excludes>
            <exclude>**/BaseTest.java</exclude>
          </excludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
+1
source

Source: https://habr.com/ru/post/1776711/


All Articles