首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Maven不会运行scala测试

Maven不会运行scala测试
EN

Stack Overflow用户
提问于 2015-02-06 00:09:09
回答 2查看 1.8K关注 0票数 5

我使用的是maven scala测试插件,就像here描述的那样。我定义了两个测试类,并将它们放在src/test/scala

测试如下所示:

代码语言:javascript
复制
class LoginTest extends FlatSpec with ShouldMatchers with WebBrowser with Eventually with IntegrationPatience {
    ...
}

我的pom.xml包含以下依赖项/配置:

代码语言:javascript
复制
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.11</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.44.0</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.scalatest</groupId>
        <artifactId>scalatest_2.11</artifactId>
        <version>2.2.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <skipTests>true</skipTests>
            </configuration>
        </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>

        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.15.2</version>
            <executions>
                <execution>
                    <id>scala-compile</id>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

当我运行mvn test时,我得到了这样的消息:

代码语言:javascript
复制
[INFO] --- scalatest-maven-plugin:1.0:test (test) @ selenium ---
Discovery starting.
Discovery completed in 30 milliseconds.
Run starting. Expected test count is: 0
DiscoverySuite:
Run completed in 91 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.

Intellij调用测试会带来一条消息:

代码语言:javascript
复制
0 test class found in package '<default package>'
EN

回答 2

Stack Overflow用户

发布于 2015-10-22 22:44:39

有类似的问题,mvn安装发现测试,mvn测试没有

票数 1
EN

Stack Overflow用户

发布于 2017-01-03 21:03:55

我必须做两个改变才能在我的情况下工作:

表示不跳过测试报告,删除空格:<filereports>WDFTestSuite.txt</filereports>

  • Explicitly to
  1. <skipTests>false</skipTests>

因此,配置块如下所示:

代码语言:javascript
复制
                    <configuration>
                        <reportsDirectory>${project.build.directory}/surefire-reports</reportsDirectory>
                        <junitxml>.</junitxml>
                        <filereports>WDFTestSuite.txt</filereports>
                        <skipTests>false</skipTests>
                    </configuration>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28348696

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档