Wednesday, 12 October 2016

XML : Scalatest from Maven: How to tag (and filter out) an entire Suite?

I have a Maven project and I'm using the scalatest-maven-plugin to configure scalatest. I'm using scalatest 3.0.0 however I can't manage to tag and filter out an entire Suite.

As reference, I have used the blog Tag a whole ScalaTest suite (update for Java 8) but this doesn't seem to work from Maven.

I created a new Skip tag defined as follows:

  package tags;    import java.lang.annotation.*;    @org.scalatest.TagAnnotation  @Retention(RetentionPolicy.RUNTIME)  @Target({ElementType.METHOD, ElementType.TYPE})  public @interface Skip {}    

Then I tag my test Suite like this:

  @tags.Skip  class AcceptanceTest extends FeatureSpec { ...     

I then configure my scalatest-maven-plugin like this:

  <plugin>      <groupId>org.scalatest</groupId>      <artifactId>scalatest-maven-plugin</artifactId>      <configuration>          <tagsToExclude>tags.Skip</tagsToExclude>      </configuration>      <executions>          <execution>              <id>test</id>              <goals>                  <goal>test</goal>              </goals>          </execution>      </executions>  </plugin>        

Then running mvn clean install -X I see (which correctly passes the -l Tag exclusion CLI argument to Scalatest):

  [DEBUG] Forking ScalaTest via: cmd.exe /X /C "java -Dbasedir=mydir           org.scalatest.tools.Runner -R -l tags.Skip ...    

but the AcceptanceTest Suite gets executed nevertheless. I have also tried tagging the Suite like this without success:

  class AcceptanceTest extends Tag("tags.Skip") with FeatureSpecLike { ...          

No comments:

Post a Comment