Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scalatest maven plugin doesn't honour maven.test.skip #466

Open
dantwining opened this issue Dec 17, 2014 · 20 comments
Open

scalatest maven plugin doesn't honour maven.test.skip #466

dantwining opened this issue Dec 17, 2014 · 20 comments

Comments

@dantwining
Copy link

It seems impossible to skip the running of scalatest.

From http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html "maven.test.skip is honored by Surefire, Failsafe and the Compiler Plugin." - I would expect scalatest to honour this also.

(background - due to some unknown compatibility, some unrelated scalatest tests are failing to run for some developers on our system. we need to be able to skip tests in order to build locally whilst the problem is identified/resolved)

@strubell
Copy link

+1 our team would also find this useful

@lukastymo
Copy link

+1

@giftig
Copy link

giftig commented Mar 30, 2015

+1 my build just failed because maven didn't compile the tests because I specified this parameter, and then scalatest tried to run a class file which didn't exist :(

@ryan-williams
Copy link

+1

seems like using both -Dmaven.test.skip -DskipTests skips both compilation and execution?

@giftig
Copy link

giftig commented Jun 4, 2015

@ryan-williams Yeah, I found that workaround too; worth noting that that will do the trick, but it does seem scalatest doesn't properly support -Dmaven.test.skip

@rfries
Copy link
Contributor

rfries commented Jun 5, 2015

@dantwining, I have not been able to reproduce this in simple tests I have tried (e.g. "mvn -Dmaven.test.skip=true clean test" with a simple project does seem to skip the tests); so the problem may involve a more complicated scenario. Could you let me know what maven version and command line you are using (or even better a project w/ pom that exhibits the problem) so I can further try to reproduce the issue?

@giftig, could you clarify which parameter you used? "maven.test.skip" is supposed to skip compilation, while "skipTests" is not. [http://maven.apache.org/surefire/maven-surefire-plugin/examples/skipping-test.html]

@giftig
Copy link

giftig commented Jun 5, 2015

@rfries I used both flags, which caused test compilation and running to be skipped. Just using the maven.test.skip flag had no effect on scalatest; maven didn't compile the sources, but scalatest assumed it had and tried to run the test suites. Since the tests aren't even compiled with maven.test.skip specified, that flag should also imply -skipTests to scalatest, IMO.

@rfries
Copy link
Contributor

rfries commented Jun 5, 2015

@giftig, I set up a simple mixed scala/java project using the plugin, and at least in that scenario, -Dmaven.test.skip is skipping the tests. However, there is a definite difference in how the runner is handled depending on which flag I use. With -DskipTests, the runner doesn't run at all, and there is just a message at INFO that says "Tests are skipped." However, with -Dmaven.test.skip, the runner actually starts, but it never selects any tests (when this happens, it prints "Run starting. Expected test count is: 0" near the top of the runner output, and number of tests succeeded, failed, etc are all 0).

I would like to figure out if there is a maven configuration issue that is responsible for the different results we are seeing... the pom.xml I am using is here: https://gist.github.com/rfries/04843afa7b71853146aa

Can you provide some more information about the project you are seeing this issue in?

@giftig
Copy link

giftig commented Jun 9, 2015

@rfries The project is a private one, I'm afraid, but a detail which may be important is that my pom specifies the class names of suites to run directly - I suspect it may be seeing that and trying to run that class despite the class not being compiled.

<suites>com.mydomain.myawesomeproject.UnitSuite</suites>

Presumably in the absence of directly specifying the suite, it will try to find classes to run, and since they haven't been compiled, not find any.

@strubell
Copy link

If this helps, we're seeing this issue in the following pom: https://github.com/factorie/factorie/blob/master/pom.xml

Perhaps I should open a separate issue, but another related problem, which is not resolved by -DskipTests, is that scalatest also doesn't respect maven syntax for running a specific test (or subset of tests), e.g. -Dtest=TestX -- surefire will run only the specified test, then scalatest runs all discovered scalatests.

@bvenners
Copy link
Contributor

Thanks for letting us know about the specific test syntax, and also the link to the pom. We'll try again to reproduce it. We have this year unfortunately been trying to get the overwhelming task of finishing the 3.0 release and have not had many cycles to deal with the issues. After the 3.0 release we will do an issue fixing release.

@invkrh
Copy link

invkrh commented Nov 30, 2016

Is this fixed ?

@rehanone
Copy link

This is still a big problem as we want to ignore the tests for mvn deploy. This issue has been reported in 2014! Any chance of getting it done?

@mlin6436
Copy link

yep, we are having this problem as well, any prospect of getting it done?

@aramesh117
Copy link

This is such a basic requirement that's been open since 2014. Can I contribute a pull request?

@iaspradeep
Copy link

Please use the below workaround. <properties><skipTests>true</skipTests></properties>
On the plugin section
<plugin> <groupId>org.scalatest</groupId> <artifactId>scalatest-maven-plugin</artifactId> <version>1.0</version> <executions> <execution> <id>test</id> <goals> <goal>test</goal> </goals> </execution> </executions> </plugin>

@afoerster
Copy link

afoerster commented Jun 4, 2018

You an add your own Maven property, then parameterize the skipTests tag in the plugin:

<project ...>
    <properties>
        <skipTests>false</skipTests>
    </properties>

...
<build>
    <plugins>
         <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>
                    <skipTests>${skipTests}</skipTests>
                </configuration>
                <executions>
                    <execution>
                        <id>test</id>
                        <goals>
                            <goal>test</goal>
                        </goals>
                    </execution>
                </executions>
        </plugin>
    </plugins>
</build>

</project>

Now you can run mvn package -DskipTests=true

@erond
Copy link

erond commented May 28, 2019

+1

seems like using both -Dmaven.test.skip -DskipTests skips both compilation and execution?

+1

the above workaround worked for me.

@lyrl
Copy link

lyrl commented Feb 16, 2022

+1
seems like using both -Dmaven.test.skip -DskipTests skips both compilation and execution?

+1

the above workaround worked for me.

-Dmaven.test.skip=true can not skip scala test, -Dmaven.test.skip -DskipTests worked

@XorSum
Copy link

XorSum commented Nov 17, 2023

This profile automatically converts -Dmaven.test.skip to -DskipTests.

<profile>
    <id>skipTestsProfile</id>
    <activation>
        <property>
            <name>maven.test.skip</name>
            <value>true</value>
        </property>
    </activation>
    <properties>
        <skipTests>true</skipTests>
    </properties>
</profile>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests