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

SkyWalker

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 nevertheless executed. I have also tried tagging the Suite like this without success:

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

To separate execution of integration tests I used maven profiles:

    <profiles>
    <profile>
        <id>default-test</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest-maven-plugin</artifactId>
                    <version>1.0</version>
                    <configuration>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <filereports>WDF TestSuite.txt</filereports>
                        <tagsToExclude>org.example.testkit.annotations.IntegrationTestSuite</tagsToExclude>
                    </configuration>
                    <executions>
                        <execution>
                            <id>test</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
    <profile>
        <id>integration-test</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>scala-maven-plugin</artifactId>
                </plugin>
                <plugin>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest-maven-plugin</artifactId>
                    <version>1.0</version>
                    <configuration>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <filereports>WDF TestSuite.txt</filereports>
                        <tagsToInclude>org.example.testkit.annotations.IntegrationTestSuite</tagsToInclude>
                    </configuration>
                    <executions>
                        <execution>
                            <id>test</id>
                            <goals>
                                <goal>test</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>

Then I marked integration tests accordingly

@IntegrationTestSuite
class ExampleTest extends PropSpec with MockitoSugar with BeforeAndAfterAll with EndpointTestHelper {

to run unit tests I run

mvn test

for integration tests

mvn test -Pintegration-test

UPD:

package org.example.testkit.annotations;

import org.scalatest.TagAnnotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@TagAnnotation
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
public @interface IntegrationTestSuite {}

We use scala 2.11, scalatest 2.2.6, maven 2, java 8.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to run a single test in scalatest from maven

From Dev

How to configure ScalaTest to abort a suite if a test fails?

From Dev

How to run entire JUnit Test Suite from within code

From Dev

How to filter out an object between the <script> tag

From Dev

maven - how to exclude an entire module on from war

From Dev

TestNG - How to force end the entire test suite from the BeforeSuite annotation if a condition is met

From Dev

How to remove a specific tag from the entire html page using jsoup

From Dev

How to remove a specific tag from the entire html page using jsoup

From Dev

How to set the PermSize for scalatest-maven-plugin?

From Dev

How to filter out from a list of items

From Dev

How to filter out values from array

From Dev

How to filter out specific strings from a string

From Dev

ScalaTest - how to use forEvery without printing the entire collection?

From Dev

Disable scalatest logging statements when running tests from maven

From Dev

How to skip/mark incomplete entire test suite in PHPUnit?

From Dev

How to skip/mark incomplete entire test suite in PHPUnit?

From Dev

How to filter out the duplicates?

From Dev

How to filter out "Nothing" values from Elm Array?

From Java

how to filter out a null value from spark dataframe

From Java

How to filter out numbers from a string if it matches the template?

From Dev

How to filter out WCF Async method from Services .NET

From Dev

Integration Tests in Elixir - how to filter out from Unit Tests

From Dev

How to filter out user defined globals in Lua from C++?

From Dev

How to filter out false values from the list in racket

From Dev

How do you filter out data that exists in a list from a Query?

From Dev

How to filter out nodes from an XML using PERL script

From Dev

Wikipedia: Processing from dumps, how to filter out hidden categories?

From Dev

How to use swift flatMap to filter out optionals from an array

From Dev

PowerShell how to filter out a date range from list of dates.

Related Related

  1. 1

    How to run a single test in scalatest from maven

  2. 2

    How to configure ScalaTest to abort a suite if a test fails?

  3. 3

    How to run entire JUnit Test Suite from within code

  4. 4

    How to filter out an object between the <script> tag

  5. 5

    maven - how to exclude an entire module on from war

  6. 6

    TestNG - How to force end the entire test suite from the BeforeSuite annotation if a condition is met

  7. 7

    How to remove a specific tag from the entire html page using jsoup

  8. 8

    How to remove a specific tag from the entire html page using jsoup

  9. 9

    How to set the PermSize for scalatest-maven-plugin?

  10. 10

    How to filter out from a list of items

  11. 11

    How to filter out values from array

  12. 12

    How to filter out specific strings from a string

  13. 13

    ScalaTest - how to use forEvery without printing the entire collection?

  14. 14

    Disable scalatest logging statements when running tests from maven

  15. 15

    How to skip/mark incomplete entire test suite in PHPUnit?

  16. 16

    How to skip/mark incomplete entire test suite in PHPUnit?

  17. 17

    How to filter out the duplicates?

  18. 18

    How to filter out "Nothing" values from Elm Array?

  19. 19

    how to filter out a null value from spark dataframe

  20. 20

    How to filter out numbers from a string if it matches the template?

  21. 21

    How to filter out WCF Async method from Services .NET

  22. 22

    Integration Tests in Elixir - how to filter out from Unit Tests

  23. 23

    How to filter out user defined globals in Lua from C++?

  24. 24

    How to filter out false values from the list in racket

  25. 25

    How do you filter out data that exists in a list from a Query?

  26. 26

    How to filter out nodes from an XML using PERL script

  27. 27

    Wikipedia: Processing from dumps, how to filter out hidden categories?

  28. 28

    How to use swift flatMap to filter out optionals from an array

  29. 29

    PowerShell how to filter out a date range from list of dates.

HotTag

Archive