Coder Social home page Coder Social logo

scalatest-maven-plugin's Introduction

ScalaTest

Build Status

ScalaTest is a free, open-source testing toolkit for Scala and Java programmers.

Official Website: http://www.scalatest.org/

Using ScalaTest

Setup

Please visit Download and Setup for download and setup instructions.

Quick Start

Please visit Quick Start for steps to get started quickly.

Building ScalaTest

Pre-Requisites

The followings are needed for building ScalaTest:

use the following SBT options instead:

SBT_OPTS="-Xms512M -Xmx3000M -Xss1M -XX:NewRatio=8"

Building and Running Tests

This command will build and run the regular tests:

$ sbt test

To include flicker tests, you'll need to set environment variable SCALATEST_RUN_FLICKER_TESTS=true:

> export SCALATEST_RUN_FLICKER_TESTS=true
> sbt test

To run generated all tests, you'll need to increase maximum heap size to at least -Xmx5000M, and use this command instead:

$ rm -rf gentests
$ sbt gentests/test

You can also run different groups generated tests separately:

$ rm -rf gentests
$ sbt genMustMatchersTests1/test
$ sbt genMustMatchersTests2/test
$ sbt genMustMatchersTests3/test
$ sbt genMustMatchersTests4/test
$ sbt genGenTests/test
$ sbt genTablesTests/test
$ sbt genInspectorsTests/test
$ sbt genInspectorsShorthandsTests1/test
$ sbt genInspectorsShorthandsTests2/test
$ sbt genTheyTests/test
$ sbt genContainTests1/test
$ sbt genContainTests2/test
$ sbt genSortedTests/test
$ sbt genLoneElementTests/test
$ sbt genEmptyTests/test

What it does is simply switch to gentests project and run test.

To run scala-js tests:

$ sbt scalatestAppJS/clean
$ sbt scalacticTestJS/test:compile
$ sbt scalacticTestJS/test
$ sbt scalatestTestJS/test:compile
$ sbt scalatestTestJS/test

To run scala-native tests:

$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalatestAppNative/clean
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalacticTestNative/test:compile
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalacticTestNative/test
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalatestTestNative/test:compile
$ sbt -Dscalatest.skip.jdk.check=true ++2.11.12 scalatestTestNative/test

Building Examples

You can build examples project using this command:

$ sbt examples/compile

Packaging

You can package the ScalaTest JAR file using this command:

$ sbt package

The resulting JAR file will be produced in target/scala-2.11/.

You can also publish it to your local Ivy repository using this command:

$ sbt publishLocal

Or publish it to local maven repository using this command:

$ sbt publishM2

Publishing

To publish to Sonatype, you first need to make sure you have the following:

  • A GPG client is installed on your command line path. For more information, please refer to GNU Privacy Guard Website.
  • You have created your GPG keys and distributed your public key to hkp://pool.sks-keyservers.net/. For more information, please refer to How To Generate PGP Signatures With Maven.
  • You have been granted the right to publish using org.scalatest and org.scalactic domain.

By default, ScalaTest build will read your Sonatype credentials from ~/.ivy2/.credentials, which is a properties file that looks like this:

realm=Sonatype Nexus Repository Manager
host=oss.sonatype.org
user=xxxxxxxx
password=xxxxxxxx

You can use SCALATEST_NEXUS_LOGIN and SCALATEST_NEXUS_PASSWORD environment variables to override Sonatype credentials.

For signing, ScalaTest build will use ~/.gnupg/secring.gpg by default and prompt for GPG passphase if required. Alternatively you can use SCALATEST_GPG_FILE to use a different GPG file, and use SCALATEST_GPG_PASSPHASE to provide GPG passphase to avoid input prompt.

If you would like to export a particular private key into a separate GPG file, you can use the following command:

$ gpg --export-secret-keys [email protected] > example-secret-key.gpg

With Sonatype credentials and GPG file in place, you can now publish to Sonatype.

Before publishing any patch release, binary compatibility with previous version should be checked:

$ sbt ++2.11.12 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestCore/package scalatestCore/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFeatureSpec/package scalatestFeatureSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFlatSpec/package scalatestFlatSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFreeSpec/package scalatestFreeSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFunSuite/package scalatestFunSuite/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFunSpec/package scalatestFunSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestPropSpec/package scalatestPropSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestRefSpec/package scalatestRefSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestWordSpec/package scalatestWordSpec/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestDiagrams/package scalatestDiagrams/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestMatchersCore/package scalatestMatchersCore/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestShouldMatchers/package scalatestShouldMatchers/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestMustMatchers/package scalatestMustMatchers/mimaReportBinaryIssues
$ sbt ++2.11.12 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestCoreJS/package scalatestCoreJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFeatureSpecJS/package scalatestFeatureSpecJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFlatSpecJS/package scalatestFlatSpecJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFreeSpecJS/package scalatestFreeSpecJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFunSuiteJS/package scalatestFunSuiteJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestFunSpecJS/package scalatestFunSpecJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestPropSpecJS/package scalatestPropSpecJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestWordSpecJS/package scalatestWordSpecJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestDiagramsJS/package scalatestDiagramsJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestMatchersCoreJS/package scalatestMatchersCoreJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestShouldMatchersJS/package scalatestShouldMatchersJS/mimaReportBinaryIssues
$ sbt ++2.11.12 scalatestMustMatchersJS/package scalatestMustMatchersJS/mimaReportBinaryIssues

$ sbt ++2.12.17 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestCore/package scalatestCore/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFeatureSpec/package scalatestFeatureSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFlatSpec/package scalatestFlatSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFreeSpec/package scalatestFreeSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFunSuite/package scalatestFunSuite/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFunSpec/package scalatestFunSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestPropSpec/package scalatestPropSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestRefSpec/package scalatestRefSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestWordSpec/package scalatestWordSpec/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestDiagrams/package scalatestDiagrams/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestMatchersCore/package scalatestMatchersCore/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestShouldMatchers/package scalatestShouldMatchers/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestMustMatchers/package scalatestMustMatchers/mimaReportBinaryIssues
$ sbt ++2.12.17 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestCoreJS/package scalatestCoreJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFeatureSpecJS/package scalatestFeatureSpecJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFlatSpecJS/package scalatestFlatSpecJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFreeSpecJS/package scalatestFreeSpecJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFunSuiteJS/package scalatestFunSuiteJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestFunSpecJS/package scalatestFunSpecJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestPropSpecJS/package scalatestPropSpecJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestWordSpecJS/package scalatestWordSpecJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestDiagramsJS/package scalatestDiagramsJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestMatchersCoreJS/package scalatestMatchersCoreJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestShouldMatchersJS/package scalatestShouldMatchersJS/mimaReportBinaryIssues
$ sbt ++2.12.17 scalatestMustMatchersJS/package scalatestMustMatchersJS/mimaReportBinaryIssues

$ sbt ++2.13.12 scalactic/package scalactic/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestCore/package scalatestCore/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFeatureSpec/package scalatestFeatureSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFlatSpec/package scalatestFlatSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFreeSpec/package scalatestFreeSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFunSuite/package scalatestFunSuite/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFunSpec/package scalatestFunSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestPropSpec/package scalatestPropSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestRefSpec/package scalatestRefSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestWordSpec/package scalatestWordSpec/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestDiagrams/package scalatestDiagrams/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestMatchersCore/package scalatestMatchersCore/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestShouldMatchers/package scalatestShouldMatchers/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestMustMatchers/package scalatestMustMatchers/mimaReportBinaryIssues
$ sbt ++2.13.12 scalacticJS/package scalacticJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestCoreJS/package scalatestCoreJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFeatureSpecJS/package scalatestFeatureSpecJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFlatSpecJS/package scalatestFlatSpecJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFreeSpecJS/package scalatestFreeSpecJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFunSuiteJS/package scalatestFunSuiteJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestFunSpecJS/package scalatestFunSpecJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestPropSpecJS/package scalatestPropSpecJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestWordSpecJS/package scalatestWordSpecJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestDiagramsJS/package scalatestDiagramsJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestMatchersCoreJS/package scalatestMatchersCoreJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestShouldMatchersJS/package scalatestShouldMatchersJS/mimaReportBinaryIssues
$ sbt ++2.13.12 scalatestMustMatchersJS/package scalatestMustMatchersJS/mimaReportBinaryIssues

To publish scalatest modules for jvm, js, native and dotty, use the following commands:

$ ./publish.sh

scalatest-maven-plugin's People

Contributors

andreoss avatar bvenners avatar cerveada avatar cheeseng avatar chrisalbright avatar cstroe avatar gcberger avatar gliptak avatar grigorievnick avatar isomarcte avatar jakobbraun avatar katrinsharp avatar metteo avatar sdruzkin avatar seanf avatar veysiertekin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

scalatest-maven-plugin's Issues

how to set `<environmentVariables>`

Hi there,
I'm trying to include some environmental variables into my test:

<environmentVariables>DATADIR="../DDDDD"</environmentVariables>

However, I'm getting:

Caused by: org.apache.maven.plugin.PluginConfigurationException: Unable to parse configuration of
mojo org.scalatest:scalatest-maven-plugin:2.0.2:test for parameter environmentVariables: 
Cannot assign configuration entry 'environmentVariables' with value 'DATADIR="../DDDDD"' of type java.lang.String to 
property of type java.util.Map

can you please help me how to add correctly <environmentVariables>, or systemProperties? Or a link to documentation (i could find any example)

No test were executed

Discovery starting.
Discovery completed in 73 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 115 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
No tests were executed.

No test runned. Why?
Project => https://github.com/Roland4444/Zerber.git

'java' is not recognized as an internal or external command

Hello,

I am trying to use your plugin to run tests ('mvn test') but I get this error message: 'java' is not recognized as an internal or external command

I can definitely run 'java' in the terminal I'm using (C:/Program Files (x86)/Git/bin/sh.exe within an Emacs buffer).

Also, I can successfully run tests with 'mvn test' within a classical cmd.exe terminal.

I'm not sure what the problem is, any idea ?

tagsToInclude with more tags

Setting "Tag1 Tag2" in tagsToInclude configuration option runs tests that has Tag1 OR Tag2 tags. It probably should run that tests which have Tag1 AND Tag2.

Scalatest Maven Plugin Roadmap?

Hi scalatest team (@cheeseng),

First of all congratulations for your great job. We are using scalatest library at my company in several Scala projects and it's very useful for us.

With the new release of Scala 2.13 a new release of other libraries and plugins which depend on Scala will be probably needed.

In my team we are planning to upgrade Scala version in a middle term, and we have to use Maven, therefore this plugin is quite relevant for us.

I understand you'll have a lot of work with other important projects, but I'd like to know if you have plans to evolve the Scalatest Maven Plugin in the near future.

If I can help you, let me know.

Thank you very much.

Scalatest 3 Support?

Hi there - I noticed this plugin is still tied to scalatest 2, and I had some troubles trying to run it on 3, although I can't say if it was actually because the plugin is incompatible or because there are changes to my own code that're necessary, but in either case it's nonobvious if the plugin works with scalatest 3.

Would be nice to have some clarification in the documentation.

Thanks!

scalatest 2.2.1 with htmlreporters fails with NoClassDefFoundError

Using the plugin with scalatest 2.2.1 and htmlreporters enabled results in a NoClassDefFoundError failure (and a plugin hang).

[INFO] --- scalatest-maven-plugin:1.0:test (test) @ platformtest ---
An exception or error caused a run to abort. This may have been caused by a problematic custom reporter.
java.lang.NoClassDefFoundError: org/pegdown/PegDownProcessor
at org.scalatest.tools.HtmlReporter.(HtmlReporter.scala:115)
at org.scalatest.tools.ReporterFactory.createHtmlReporter(ReporterFactory.scala:182)
at org.scalatest.tools.ReporterFactory.getReporterFromConfiguration(ReporterFactory.scala:233)
at org.scalatest.tools.ReporterFactory$$anonfun$createReportersFromConfigurations$1.apply(ReporterFactory.scala:242)
at org.scalatest.tools.ReporterFactory$$anonfun$createReportersFromConfigurations$1.apply(ReporterFactory.scala:241)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:245)
at scala.collection.Iterator$class.foreach(Iterator.scala:743)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1177)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at org.scalatest.tools.ReporterConfigurations.foreach(ReporterConfiguration.scala:43)
at scala.collection.TraversableLike$class.map(TraversableLike.scala:245)
at org.scalatest.tools.ReporterConfigurations.map(ReporterConfiguration.scala:43)
at org.scalatest.tools.ReporterFactory.createReportersFromConfigurations(ReporterFactory.scala:241)
at org.scalatest.tools.ReporterFactory.getDispatchReporter(ReporterFactory.scala:245)
at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2720)
at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1043)
at org.scalatest.tools.Runner$.main(Runner.scala:860)
at org.scalatest.tools.Runner.main(Runner.scala)
Caused by: java.lang.ClassNotFoundException: org.pegdown.PegDownProcessor
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
... 19 more

java.class.path system property

When I run a JUnit test in java, and I do System.getProperty("java.class.path") I get a list of all the jars in scope defined using maven dependencies.
When I have a scalatest I do the same, I just get a maven plexus jar. This happens at command line when running mvn test -Dsuite-<>. When I run it through intellij, it also works.

How do I get scalatest to pass/set java.class.path. I am using that to setup another property to test my hadoop job.

Enabling the Post-Integration-test phase to run on test failure

Hello,

I want to use the scalatest-maven-plugin to run dockerized integration tests. Similarly to #45 I was stuck because a failing test would fail the build immediately. One solution that I came up with for remedying this situation was to make a flag, runVerifyOnFailure that would cause the setup for a verify stage to be preformed within the test phase if there was a failure. Then you would have to include the verify stage on your plugin config and that is where it would detect the failures. Because the verfiy stage runs after the post-integration-test phase in maven, the docker cleanup would have already happened, remedying the issue.

I'm just seeking feedback on if this would even be something feasible that the maintainers would want in the project. Heres a rough draft of what I was thinking on my fork: nab0310@65913b2

Automate release to Maven Central

Looking at #36 it seems that a release to Maven Central of scalatest-maven-plugin is not automated and readily available to contributors via a script/command.

I have a suggestion to automate release process, we could use a Devops bot like Rultor and define the release routine in a script.

That way, certain contributors with the permissions defined on a Yaml file can easily comment on a issue or PR in this repository telling the bot to release to maven central with a given version.
It can then be defined that the bot runs a battery of tests, tags a release for github and releases to maven central.

FYI @cheeseng @bvenners

How to include scala test results in maven site?

It's not clear to me how to include the results for the scalatest-maven-plugin in the results for the maven-site-plugin.

I've attempted placing the scalatest-maven-plugin in the reporting plugins when list, but am getting an exception when attempting to generate the site.

What am I missing?

                <plugin>
                    <groupId>org.scalatest</groupId>
                    <artifactId>scalatest-maven-plugin</artifactId>
                    <version>2.0.0</version>
                    <configuration>
                        <argLine>-Xms256m -Xmx256m -Djava.awt.headless=true</argLine>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <htmlreporters>${project.build.directory}/html</htmlreporters>
                        <filereports>WDF TestSuite.txt</filereports>
                        <systemProperties>
                            ...
                        </systemProperties>
                        <tagsToInclude>${scalatest.includedTags}</tagsToInclude>
                        <tagsToExclude>${scalatest.excludedTags}</tagsToExclude>
                    </configuration>
                </plugin>
javax.servlet.ServletException: org.apache.maven.doxia.siterenderer.RendererException: Error generating scalatest-maven-plugin:2.0.0:reporter report
    at org.apache.maven.plugins.site.run.DoxiaFilter.doFilter (DoxiaFilter.java:172)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle (Server.java:499)
    at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable (HttpConnection.java:258)
    at org.eclipse.jetty.io.AbstractConnection$2.run (AbstractConnection.java:544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555)
    at java.lang.Thread.run (Thread.java:834)
Caused by: org.apache.maven.doxia.siterenderer.RendererException: Error generating scalatest-maven-plugin:2.0.0:reporter report
    at org.apache.maven.plugins.site.render.ReportDocumentRenderer.renderDocument (ReportDocumentRenderer.java:241)
    at org.apache.maven.plugins.site.run.DoxiaFilter.doFilter (DoxiaFilter.java:150)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle (Server.java:499)
    at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable (HttpConnection.java:258)
    at org.eclipse.jetty.io.AbstractConnection$2.run (AbstractConnection.java:544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555)
    at java.lang.Thread.run (Thread.java:834)
Caused by: org.apache.maven.reporting.MavenReportException: Failure generating ScalaTest report
    at org.scalatest.tools.maven.ReporterMojo.generate (ReporterMojo.java:82)
    at org.apache.maven.plugins.site.render.ReportDocumentRenderer.renderDocument (ReportDocumentRenderer.java:235)
    at org.apache.maven.plugins.site.run.DoxiaFilter.doFilter (DoxiaFilter.java:150)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle (Server.java:499)
    at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable (HttpConnection.java:258)
    at org.eclipse.jetty.io.AbstractConnection$2.run (AbstractConnection.java:544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555)
    at java.lang.Thread.run (Thread.java:834)
Caused by: java.io.FileNotFoundException: /var/folders/6j/j96x43893xd3vst_44_w7pqm0000gn/T/tempScalaTestOutput.txt (No such file or directory)
    at java.io.FileInputStream.open0 (Native Method)
    at java.io.FileInputStream.open (FileInputStream.java:219)
    at java.io.FileInputStream.<init> (FileInputStream.java:157)
    at java.io.FileReader.<init> (FileReader.java:75)
    at org.scalatest.tools.maven.ReporterMojo.getScalaTestOutputFromFile (ReporterMojo.java:107)
    at org.scalatest.tools.maven.ReporterMojo.generate (ReporterMojo.java:74)
    at org.apache.maven.plugins.site.render.ReportDocumentRenderer.renderDocument (ReportDocumentRenderer.java:235)
    at org.apache.maven.plugins.site.run.DoxiaFilter.doFilter (DoxiaFilter.java:150)
    at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter (ServletHandler.java:1652)
    at org.eclipse.jetty.servlet.ServletHandler.doHandle (ServletHandler.java:585)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:143)
    at org.eclipse.jetty.security.SecurityHandler.handle (SecurityHandler.java:577)
    at org.eclipse.jetty.server.session.SessionHandler.doHandle (SessionHandler.java:223)
    at org.eclipse.jetty.server.handler.ContextHandler.doHandle (ContextHandler.java:1127)
    at org.eclipse.jetty.servlet.ServletHandler.doScope (ServletHandler.java:515)
    at org.eclipse.jetty.server.session.SessionHandler.doScope (SessionHandler.java:185)
    at org.eclipse.jetty.server.handler.ContextHandler.doScope (ContextHandler.java:1061)
    at org.eclipse.jetty.server.handler.ScopedHandler.handle (ScopedHandler.java:141)
    at org.eclipse.jetty.server.handler.HandlerWrapper.handle (HandlerWrapper.java:97)
    at org.eclipse.jetty.server.Server.handle (Server.java:499)
    at org.eclipse.jetty.server.HttpChannel.handle (HttpChannel.java:311)
    at org.eclipse.jetty.server.HttpConnection.onFillable (HttpConnection.java:258)
    at org.eclipse.jetty.io.AbstractConnection$2.run (AbstractConnection.java:544)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob (QueuedThreadPool.java:635)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run (QueuedThreadPool.java:555)
    at java.lang.Thread.run (Thread.java:834)

broken with Scala 2.13

when I run scalatest with Scala 2.13 the plugin hangs with this error in console

[INFO] --- scalatest-maven-plugin:2.0.0:test (test) @ my-app ---
An exception or error caused a run to abort. This may have been caused by a problematic custom reporter.
java.lang.NoClassDefFoundError: scala/Serializable
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
	at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
	at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
	at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
	at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1368)
	at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24(Runner.scala:1033)
	at org.scalatest.tools.Runner$.$anonfun$runOptionallyWithPassFailReporter$24$adapted(Runner.scala:1011)
	at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1509)
	at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:1011)
	at org.scalatest.tools.Runner$.main(Runner.scala:827)
	at org.scalatest.tools.Runner.main(Runner.scala)
Caused by: java.lang.ClassNotFoundException: scala.Serializable
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
	... 19 more

Specify URL in the pom.xml

Currently, this plugin does not specify a URL in the pom.xml. By that it inherits the URL from its parent (org.sonatype.oss:oss-parent)

Solution:
Add a URL.

Unable to locate logback.xml from scalatest

I am using scalatest-maven-plugin with a config which looks like this

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
        <!-- enable scalatest -->
        <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>MyProj_TestSuite.txt</filereports>
                <forkMode>never</forkMode>
            </configuration>
            <executions>
                <execution>
                    <id>test</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I have a logback.xml in my src/test/resources which gets copied over to target/classes
Have spent a whole day to figure out why this is not being picked up -- using the following

<runpath> ${project.basedir}/target/classes </runpath>

If I run it like this

mvn test -Dlogback.configurationFile=./src/test/resources/logback.xml - it works

So I am wondering if you can please help me understand how to do this from inside the pom.xml

Thank you

Guice Configuration Errors when running tests

I have few test classes defined in my maven-play2 project setup. All tests run fine from ScalaIDE when running as ScalaTest Suite/File/Package. But when I try to run it via maven command line it fails.
It also ignores @ignore decoration on test class and still runs it.

Here's the stacktrace
Cause: com.google.inject.ConfigurationException: Guice configuration errors:

  1. No implementation for com.mycomp.myproj.kap.KapDaoClient was bound.
    while locating com.mycomp.myproj.kap.KapDaoClient
    for the 1st parameter of com.mycomp.myproj.kap.KapServices

1 error
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1045)
at com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1004)
at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1054)
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:409)
at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:404)
at play.api.inject.ContextClassLoaderInjector$$anonfun$instanceOf$2.apply(Injector.scala:117)
at play.api.inject.ContextClassLoaderInjector.withContext(Injector.scala:126)
at play.api.inject.ContextClassLoaderInjector.instanceOf(Injector.scala:117)
at com.mycomp.myproj.tests.functional.MetadataServiceSpec.(MetadataServiceSpec.scala:20)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
Run completed in 4 seconds, 585 milliseconds.
Total number of tests run: 4
Suites: completed 2, aborted 4
Tests: succeeded 2, failed 2, canceled 0, ignored 0, pending 0
*** 4 SUITES ABORTED ***
*** 2 TESTS FAILED ***

Plugin Configuration

		<plugin>
	      <groupId>org.scalatest</groupId>
	      <artifactId>scalatest-maven-plugin</artifactId>
	      <version>2.0.0</version>
		  <configuration>
		    <reportsDirectory>${project.build.directory}/target/surefire-reports</reportsDirectory>
		    <junitxml>.</junitxml>
		    <filereports>WDF_TestSuite.txt</filereports>
		    <parallel>false</parallel>
		    <forkMode>never</forkMode>
		  </configuration>
		  <executions>
		    <execution>
		      <id>test</id>
		      <goals>
		        <goal>test</goal>
		      </goals>
		    </execution>
		  </executions>
		</plugin>

Using fork mode "never" uses wrong resource directory

In the scalatest Maven plugin 1.0-M2, if configuration contains <forkMode>never</forkMode>, src/main/resources will be used instead of the expected src/test/resources. Using fork mode once correctly uses the test resources.

Dependency missing for `com/vladsch/flexmark/util/ast/Node`

When using the latest plugin 2.0.2 with scalatest 3.2.11 and the following configuration:

      <plugin>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest-maven-plugin</artifactId>
        <version>2.0.2</version>
        <configuration>
          <reportsDirectory>${project.build.directory}/test-results/scalatest</reportsDirectory>
          <junitxml>.</junitxml>
          <htmlreporters>${project.build.directory}/site/scalatest</htmlreporters>

        </configuration>
        <executions>
          <execution>
            <id>test</id>
            <goals>
              <goal>test</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

a Jar hell exception with the following stacktrace was thown:

java.lang.NoClassDefFoundError: com/vladsch/flexmark/util/ast/Node
07:08
	at org.scalatest.tools.ReporterFactory.createHtmlReporter(ReporterFactory.scala:194)
07:08
	at org.scalatest.tools.ReporterFactory.getReporterFromConfiguration(ReporterFactory.scala:245)
07:08
	at org.scalatest.tools.ReporterFactory$$anonfun$createReportersFromConfigurations$1.apply(ReporterFactory.scala:254)
07:08
	at org.scalatest.tools.ReporterFactory$$anonfun$createReportersFromConfigurations$1.apply(ReporterFactory.scala:253)
07:08
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
07:08
	at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:234)
07:08
	at scala.collection.Iterator$class.foreach(Iterator.scala:891)
07:08
	at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
07:08
	at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
07:08
	at org.scalatest.tools.ReporterConfigurations.foreach(ReporterConfiguration.scala:42)
07:08
	at scala.collection.TraversableLike$class.map(TraversableLike.scala:234)
07:08
	at org.scalatest.tools.ReporterConfigurations.map(ReporterConfiguration.scala:42)
07:08
	at org.scalatest.tools.ReporterFactory.createReportersFromConfigurations(ReporterFactory.scala:253)
07:08
	at org.scalatest.tools.ReporterFactory.getDispatchReporter(ReporterFactory.scala:257)
07:08
	at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:1480)
07:08
	at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:971)
07:08
	at org.scalatest.tools.Runner$.main(Runner.scala:775)
07:08
	at org.scalatest.tools.Runner.main(Runner.scala)
07:08
Caused by: java.lang.ClassNotFoundException: com.vladsch.flexmark.util.ast.Node
07:08
	at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
07:08
	at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
07:08
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
07:08
	at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
07:08
	... 18 more

Build fails on jdk 11

1.5 is specified as target release for compiler, while jdk 11 supports only 6 and above.

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] error: Source option 5 is no longer supported. Use 6 or later.
[ERROR] error: Target option 1.5 is no longer supported. Use 1.6 or later.

Make "Given, when, then" visible

I may be wrong but I did not find it in the documentation.

It seems impossible to make "given, when, then" visible in the XML report.

Is there a way to add this option?

Feature request: forkMode always

it's useful for integration tests that contain lots of singletons, because it's hard to pick up all singletons and reset them if we want to change the configuration(which will affect those singleton objects) in another test.

Make the resolution fo java location consistent with maven ecosystem

There are two ways how to find Java binary currently in the library. java.home and JAVA_HOME.

  • JAVA_HOME is system environment variable
  • java.home is property of JVM pointing to Java version that current JVM is using

Currently, the location is taken from JAVA_HOME and only if it's not there (and that will rarely happen) it's taken from java.home.

I suggest that java.home should be the default

Some reasons why I think it should be the case:

  • surefire is also using java.home
  • running mvn from Intelij Idea will not set the JAVA_HOME so the test will not use the jvm set for the project (but java.home is set)
  • running on teamcity same problem as with Idea

Basically main problem that can happen is that I run the build under Java 8, but suddenly scalatest switches to Java 11 because it's used by my system.

If there is a need to run scalatest under different java then the rest of the bild there should be special flag for that. (But why anyone would like to do that?)

scalatest-maven-plugin can't run projects with spaces in their path

If you have a project project that has spaces in its path, scalatest-maven-plugin spawns a Scalatest runner that doesn't discover any tests:

[INFO] --- scalatest-maven-plugin:1.0:test (test) @ main-api ---
Discovery starting.
Discovery completed in 50 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 94 milliseconds.
Total number of tests run: 0
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0
No tests were executed.

We should escape any run paths we pass to Scalatest so it can properly find the test classes.

scalatest threadsafe?

We are currently using scalatest in Maven with a parallel build, this will lead to Maven warning about threadsafety:

[WARNING] *****************************************************************
[WARNING] * Your build is requesting parallel execution, but project *
[WARNING] * contains the following plugin(s) that have goals not marked *
[WARNING] * as @threadsafe to support parallel building. *
[WARNING] * While this /may/ work fine, please look for plugin updates *
[WARNING] * and/or request plugins be made thread-safe. *
[WARNING] * If reporting an issue, report it against the plugin in *
[WARNING] * question, not against maven-core *
[WARNING] *****************************************************************
[WARNING] The following plugins are not marked @threadsafe in labeler:
[WARNING] org.scalatest:scalatest-maven-plugin:2.0.0
[WARNING] Enable debug to see more precisely which goals are not marked @threadsafe.
[WARNING] *****************************************************************

Did anyone already experiment with this in multithreaded build (e.g. using -T1C option with mvn)? Or can we simply ignore this warning?

Plugin does not trigger post-integration-test phase on test failure

Hi,

I was hoping to use the ScalaTest plugin to drive some integration tests in a Maven build, but have found that I can seemingly only have the plugin fail the build during the integration-test phase (if there are test failures) or always pass it.

This is different from the failsaife plugin behaviour which will fail the overall build but allow the post-integration-test phase to run. The problem being that the build requires external services running in Docker containers so relies on the pre and post integration test phases to setup and then teardown the containers.

Is there some configuration magic I have missed that would allow this to work? Does the pending 2.0 plugin release possibly add anything that might help address this?

Many thanks!

Publish git tags

Without the tags, it isn't possible to checkout the commit that makes a concrete release version.

Scala classes not generated during the build of the mixed java and scala project

Hello , this is my POM.xml , when i try to build my project , scala classes are not generated but java classes are generated

`
4.0.0
ariskk
distributedWekaSpark
jar
0.1.0-SNAPSHOT

  <build>
    <plugins>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.3</version>
        <configuration>
              <artifactSet>
                <excludes>
                  <exclude>org.apache.hadoop:hadoop-client</exclude>
                  <exclude>org.apache.spark:spark-core_2.10</exclude>
                  <exclude>nz.ac.waikato.cms.weka:distributedWekaHadoop</exclude>
                </excludes>
              </artifactSet>
              <filters>
        <filter>
            <artifact>*:*</artifact>
            <excludes>
                <exclude>META-INF/*.SF</exclude>
                <exclude>META-INF/*.DSA</exclude>
                <exclude>META-INF/*.RSA</exclude>
            </excludes>
        </filter>
    </filters>
          <!-- put your configurations here -->
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
          </execution>
        </executions>
      </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>
        </configuration>
        <executions>
          <execution>
            <id>test</id>
             <goals>
              <goal>test</goal>
             </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
   </build>




  <dependencies>
    <dependency>
	    <groupId>org.apache.spark</groupId>
	    <artifactId>spark-core_2.10</artifactId>
	    <version>1.1.0</version>
    </dependency>
    <dependency>
	    <groupId>nz.ac.waikato.cms.weka</groupId>
	    <artifactId>distributedWekaBase</artifactId>
	    <version>1.0.6</version>
    </dependency>
    <dependency>
	    <groupId>nz.ac.waikato.cms.weka</groupId>
	    <artifactId>weka-dev</artifactId>
	    <version>3.7.11</version>
    </dependency>
    <dependency>
	    <groupId>org.scalatest</groupId>
	    <artifactId>scalatest-maven-plugin</artifactId>
	    <version>1.0</version>
	    <type>maven-plugin</type>
    </dependency>
    <dependency>
	    <groupId>org.scalatest</groupId>
	    <artifactId>scalatest_2.10</artifactId>
	    <version>2.2.3-SNAP2</version>
	    <scope>test</scope>
    </dependency>
  </dependencies>
  <organization>
    <name>University of Manchester</name>
  </organization>
  <developers>
        <developer>
            <id>ariskk</id>
            <name>Aris-Kyriakos Koliopoulos</name>
            <email>[email protected]</email>
            <organization>School of Computer Science,University or Manchester</organization>
            <organizationUrl>http://www.cs.manchester.ac.uk/</organizationUrl>
        </developer>
    </developers>
</project>`

print summary of failed tests at the end

It would be nice if we can see a summary of failed tests at the end of a run,
otherwise if we have 1000 tests and one fails, i never know, which actually failed.
this would also be similar to the surefire plugin

Provide a method by which code can be executed after ALL suites have finished

The ask here would be to implement a test listener similar to Junit mentioned in the article below.

in some cases we need to do cleanup after all the suites have finished execution.

public class TestListener extends RunListener {
@OverRide
public void testRunStarted(Description description) throws Exception {
// Called before any tests have been run.
}
@OverRide
public void testRunFinished(Result result) throws Exception {
// Called when all tests have finished
}
}

https://stackoverflow.com/questions/9903341/cleanup-after-all-junit-tests

Make the plugin toolchains aware

Could this plugin be made aware of Maven toolchains so that it use the configured JDK in the project ?

My project defines that it should be build (via maven-toolchains-plugin) with JDK 11 but I run mvn on the command line where JAVA_HOME points to JDK 8 installation and this leads to an error like:

...
[INFO] --- maven-compiler-plugin:3.8.0:testCompile (default-testCompile) @ wicketstuff-scala ---
[INFO] Toolchain in maven-compiler-plugin: JDK[/home/martin/devel/jdk-11/]
[INFO] No sources to compile
[INFO] 
[INFO] --- scala-maven-plugin:3.4.4:testCompile (test-compile) @ wicketstuff-scala ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.22.1:test (default-test) @ wicketstuff-scala ---
[INFO] Tests are skipped.
[INFO] 
[INFO] --- scalatest-maven-plugin:2.0.0:test (test) @ wicketstuff-scala ---
Discovery starting.
*** RUN ABORTED ***
  java.lang.UnsupportedClassVersionError: org/apache/wicket/ajax/markup/html/AjaxFallbackLink has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
  at java.lang.ClassLoader.defineClass1(Native Method)
  at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
  at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
  at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
  at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  ...
[INFO] ------------------------------------------------------------------------

Information how a Maven plugin could be made toolchains-aware could be found at: https://cwiki.apache.org//confluence/display/MAVENOLD/Toolchains
Here is how scala-maven-plugin does it: https://github.com/davidB/scala-maven-plugin/search?q=ToolchainManager&unscoped_q=ToolchainManager

`-Dsuites` option still runs all suites

When I run mvn test -Dsuites=com.example.FooSpec, all of my tests still run as before. In the logs, I can see that FooSpec does get instantiated first, but then I see "Discovery starting" and all the other specs still get instantiated and run:

$ mvn test -Dsuites=com.example.FooSpec

...

[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ example_2.11 ---
[INFO] Tests are skipped.
[INFO]
[INFO] --- scalatest-maven-plugin:2.0.0:test (test) @ example_2.11 ---
[INFO] Forking ScalaTest via: /bin/sh -c cd '/path/to/example' && 'java' '-Dbasedir=/path/to/example' 'org.scalatest.tools.Runner' '-R' '/path/to/example/target/classes /path/to/target/test-classes' '-s' 'com.example.FooSpec' '-w' 'com.example' '-o' '-u' '/path/to/example/target/surefire-reports/.'
18/07/21 11:36:52 INFO FooSpec: initiating some stuff
Discovery starting.
18/07/21 11:36:54 INFO BarSpec: initiating some stuff 
18/07/21 11:36:54 INFO BazSpec: initiating some stuff 

...

Discovery completed in 26 seconds, 444 milliseconds.
Run starting. Expected test count is: 170
FooSpec:
Foo
  when stuff happens
  - should confidently announce that everything will be fine
BarSpec:
Bar
  when stuff happens
  - should exhibit an unruffled demeanor
BazSpec:
Baz
  when stuff happens
  - should stride purposefully over and deal with it

Not sure what I'm missing here. How can I run just the single test I want?

Parallel flag -P deprecated in Scala Test

java.lang.IllegalArgumentException: ERROR: -p has been deprecated for a very long time and is no longer supported, to prepare for reusing it for a different purpose in the near future. Please change all uses of -p to -R

ScalaTest 3.0.4

Disabling Failsafe doesn't appear to be necessary

The documentation indicates that the Failsafe plugin should be disabled, by doing the following:

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.7</version>
        <configuration>
          <skipTests>true</skipTests>
        </configuration>
      </plugin>

This sets the -DskipTests parameter, which makes the plugin skip running its tests. I'm not entirely clear why this is required. I have tested without doing this and noticed no problems (although I also have no Java tests in this module, so the Failsafe plugin simply runs nothing).

Can anyone share more detail as to why this step is required?

Mismach of errors between maven and scalatest-maven-plugin, 'There are test failures' VS 'java.lang.ClassNotFoundException'

The issue:

If scalatest is not on the classpath when the scalatest-maven-plugin is executed, the plugin shows this error:

Error: Could not find or load main class org.scalatest.tools.Runner
Caused by: java.lang.ClassNotFoundException: org.scalatest.tools.Runner

However the Build fails with:

There are test failures -> [Help 1]

Steps to reproduce:

There are 2 fairly reasonable cases (as far as I can think of) where this could happen:

  • The plugin is executed as part of a top level pom, with no code/tests (and thus there is no need to include any dependencies), however the build pipeline is defined in the top level pom, in order to apply the build pipeline to all sub-modules.
  • The plugin is executed as part of a mixed java and scala project. As the plugin can run junit tests, there may be a purely java module which has no need for scalatest, and only relies on junit.

I have made a repo where both of these issues can be replicated with mvn clean install: demo repo.

Workaround:

This issue can be circumvented by adding a scalatest dependency at the top level of the user's project, forcing all sub-modules to include scalatest. This is demonstrated on the branch 'hotfix', in the demo repo

Please let me know if any more information is needed.

"wildcardSuites" can't find tests, "suites" can

For full details, see this StackOverflow question.

In short, discovery was failing to find my tests using the wildcardSuites option:

<wildcardSuites>com.cainc.data.etl.schema.proficiency</wildcardSuites>

By succeeds when using just the suites option:

<suites>com.cainc.data.etl.schema.proficiency.ProficiencySchemaITest</suites>

Versions:
scala.version=2.10.5
scalactic_2.10=2.2.6
scalatest_2.10=2.2.6
spark-testing-base_2.10=1.6.1_0.3.3
scala-maven-plugin=3.2.1
scalatest-maven-plugin=1.0

Relevant pom plugins:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </plugin>
        <!-- enable scalatest -->
        <plugin>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest-maven-plugin</artifactId>
            <version>1.0</version>
            <configuration>
                <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                <wildcardSuites>com.cainc.data.etl.schema.proficiency</wildcardSuites>
            </configuration>
            <executions>
                <execution>
                    <id>test</id>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

And here's the test class:

class ProficiencySchemaITest extends FlatSpec with Matchers with SharedSparkContext with BeforeAndAfter {
    private var schemaStrategy: SchemaStrategy = _
    private var dataReader: DataFrameReader = _

    before {
        val sqlContext = new SQLContext(sc)
        import sqlContext._
        import sqlContext.implicits._

        val dataInReader = sqlContext.read.format("com.databricks.spark.csv")
                                            .option("header", "true")
                                            .option("nullValue", "")
        schemaStrategy = SchemaStrategyChooser("dim_state_test_proficiency")
        dataReader = schemaStrategy.applySchema(dataInReader)
    }

    "Proficiency Validation" should "pass with the CSV file proficiency-valid.csv" in {
        val dataIn = dataReader.load("src/test/resources/proficiency-valid.csv")

        val valid: Try[DataFrame] = Try(schemaStrategy.validateCsv(dataIn))
        valid match {
            case Success(v) => ()
            case Failure(e) => fail("Validation failed on what should have been a clean file: ", e)
        }
    }
}

When I run mvn test, it can't find any tests and outputs this message:

[INFO] --- scalatest-maven-plugin:1.0:test (test) @ load-csv-into-db ---
[36mDiscovery starting.[0m
[36mDiscovery completed in 54 milliseconds.[0m
[36mRun starting. Expected test count is: 0[0m
[32mDiscoverySuite:[0m
[36mRun completed in 133 milliseconds.[0m
[36mTotal number of tests run: 0[0m
[36mSuites: completed 1, aborted 0[0m
[36mTests: succeeded 0, failed 0, canceled 0, ignored 0, pending 0[0m
[33mNo tests were executed.[0m

Forked process don't respect JAVA_HOME when calling java

With forkMode set to once or always new processes are forked to execute the tests. They start java using the command java, but in the maven ecosystem one would expect the forked processes to use $JAVA_HOME/bin/java instead. This would ensure that the same java version is used as for the build as for the test execution.

You can see the following line in your maven output when run with -X option (values in ??? are replaced with what they represent)
[14:07:24][???groupdId:artifactId???] [DEBUG] Forking ScalaTest via: /bin/sh -c cd ???basedir??? && java -Dbasedir=???basedir??? org.scalatest.tools.Runner -R '???basedir???/target/classes ???basedir???/target/test-classes' -o -u ???basedir???/target/surefire-reports/

but would expect the following

[14:07:24][???groupdId:artifactId???] [DEBUG] Forking ScalaTest via: /bin/sh -c cd ???basedir??? && $JAVA_HOME/bin/java -Dbasedir=???basedir??? org.scalatest.tools.Runner -R '???basedir???/target/classes ???basedir???/target/test-classes' -o -u ???basedir???/target/surefire-reports/

A typical symptom of this is the following error message:
Unsupported major.minor version 52.0

This happens if your java code is compiled with Java 8 and then executed with Java <8. Other combinations of Java versions will lead to slightly different error messages.

Maven build fails with version 1.0 on Windows and configuration containing suffixes

Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: C:\dev\tools\apache-maven-3.3.9
Java version: 1.8.0_101, vendor: Oracle Corporation
Java home: C:\dev\java\jdk8u101_64\jre
Default locale: en_US, platform encoding: Cp1250
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

Configuration I am using:

<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>
</configuration>
<executions>
    <execution>
        <id>test</id>
        <goals>
            <goal>test</goal>
        </goals>
        <configuration>
            <suffixes>(?&lt;!Integration)(Test|Spec)</suffixes>
        </configuration>
    </execution>
    <execution>
        <id>integration-test</id>
        <phase>integration-test</phase>
        <goals>
            <goal>test</goal>
        </goals>
        <configuration>
            <suffixes>(?&lt;=Integration)(Test|Spec)</suffixes>
        </configuration>
    </execution>
</executions>
</plugin>

<plugin>
    <groupId>net.alchim31.maven</groupId>
    <artifactId>scala-maven-plugin</artifactId>
    <version>3.2.2</version>
    <executions>
        <execution>
            <id>scala-compile-first</id>
            <phase>process-resources</phase>
            <goals>
                <goal>add-source</goal>
                <goal>compile</goal>
            </goals>
        </execution>
        <execution>
            <id>scala-test-compile</id>
            <phase>process-test-resources</phase>
            <goals>
                <goal>testCompile</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <scalaVersion>2.10.6</scalaVersion>
        <charset>UTF-8</charset>
        <args>
            <arg>-optimise</arg>
            <arg>-unchecked</arg>
            <arg>-deprecation</arg>
        </args>
    </configuration>
</plugin>

Error:

[DEBUG] Configuring mojo 'org.scalatest:scalatest-maven-plugin:1.0:test' with basic configurator -->
[DEBUG]   (f) debugForkedProcess = false
[DEBUG]   (f) debuggerPort = 5005
[DEBUG]   (f) filereports = WDF TestSuite.txt
[DEBUG]   (f) forkMode = once
[DEBUG]   (f) forkedProcessTimeoutInSeconds = 0
[DEBUG]   (f) junitxml = .
[DEBUG]   (f) logForkedProcessCommand = false
[DEBUG]   (f) outputDirectory = C:\dev\git-repos\project\target\classes
[DEBUG]   (f) project = MavenProject: com.artifact:0.0.41-SNAPSHOT @ C:\dev\git-repos\project\pom.xml
[DEBUG]   (f) reportsDirectory = C:\dev\git-repos\project\target\surefire-reports
[DEBUG]   (f) suffixes = (?<!Integration)(Test|Spec)
[DEBUG]   (f) testOutputDirectory = C:\dev\git-repos\project\target\test-classes
[DEBUG] -- end configuration --
[DEBUG] [-R, C:\dev\git-repos\project\target\classes C:\dev\git-repos\project\target\test-classes, -q, (?<!Integration)(Test|Spec), -o, -fWDF, C:\dev\git-repos\project\target\surefire-reports\TestSuite.txt, -u, C:\dev\git-repos\project\target\surefire-reports\.]
[DEBUG] Forking ScalaTest via: cmd.exe /X /C "java -Dbasedir=C:\dev\git-repos\project org.scalatest.tools.Runner -R "C:\dev\git-repos\project\target\classes C:\dev\git-repos\project\target\test-classes" -q (?<!Integration)(Test|Spec) -o -fWDF C:\dev\git-repos\project\target\surefire-reports\TestSuite.txt -u C:\dev\git-repos\project\target\surefire-reports\."
The system cannot find the file specified.

[INFO] --- scalatest-maven-plugin:1.0:test (test) @ commons ---
The system cannot find the file specified.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.512 s
[INFO] Finished at: 2016-09-30T15:11:56+02:00
[INFO] Final Memory: 35M/441M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.scalatest:scalatest-maven-plugin:1.0:test (test) on project commons: There are test failures -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.scalatest:scalatest-maven-plugin:1.0:test (test) on project commons: There are test failures
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:863)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:288)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:199)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:47)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: org.apache.maven.plugin.MojoFailureException: There are test failures
    at org.scalatest.tools.maven.TestMojo.execute(TestMojo.java:107)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:207)
    ... 26 more 

Adopt the code in Surefire Provider

@cheeseng
I am the developer of the Apache Maven Surefire plugin.

I have realized that scala test plugin has similar configurations and it is pity that your engine is not applied already in Surefire Provider.

I want to kindly ask you if you would be open for including the code into Provider.
The provider is very specific test engine and surefire only executes the engine.

The providers can be implemented by another OSS projects and the users add a dependency in plugin. Another option is that the providers are in Surefire project.

I am 6 years in the Apache and Surefire. Maybe you talked with my older colleagues and maybe you discussed the inclusion of Scala Test Provider.

AbstractScalaTestMojo.runForkingOnce usese wrong java executable

We had a build fail because it was using the java on the path rather than JAVA_HOME.
The java on the path was the default for our build server which was Java 6 and our JAVA_HOME was actually Java 8.
We had to turn forking off because of this which shouldn't be necessary.

Rather than doing the following in AbstractScalaTestMojo.runForkingOnce:
cli.setExecutable("java");
Having a jvm config property and method getEffectiveJvm like in the surefire-plugin (AbstractSurefireMojo) would be appropriate

I briefly looked at implementing it and submitting a pull request but the maven plugin versions are quite a bit different so I'm unsure how to reconcile the differences.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.