Maven没有找到scala测试

时间:2012-11-30 17:15:16

标签: eclipse scala maven

我有一个scala测试类但是当我尝试使用Maven目标'test'时 测试没有运行。我收到Maven消息“没有可以运行的测试”。即使测试位于scala测试类中。我是否需要添加额外的配置?

这是我的包装设置:

enter image description here

以下是针对pom文件运行时Maven“测试”目标的输出:

  

[INFO]扫描项目... [INFO]
  [信息]   -------------------------------------------------- ---------------------- [INFO]建筑物scala.maven.test 0.0.1-SNAPSHOT [INFO]   -------------------------------------------------- ---------------------- [INFO] [INFO] --- maven-resources-plugin:2.4.3:资源   (default-resources)@scala.maven.test --- [警告]使用平台   编码(实际上是Cp1252)来复制过滤后的资源,即构建是   平台依赖! [INFO]复制0资源[INFO] [INFO] ---   maven-scala-plugin:2.9.1:add-source(scala-compile-first)@   scala.maven.test --- [INFO]添加源目录:   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ main \ scala [INFO]添加测试   来源目录:   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ test \ scala [INFO] [INFO]   --- maven-scala-plugin:2.9.1:compile(scala-compile-first)@scala.maven.test --- [ERROR]   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ main \ java [错误]   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ main \ scala [错误]   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ test \ scala [INFO]   将2个源文件编译为   C:\ workspaces \ 29112012 \ scala.maven.test \ target \ classes [INFO] [INFO]   --- maven-compiler-plugin:2.0.2:compile(default-compile)@scala.maven.test --- [INFO]无需编译 - 所有类都由   date [INFO] [INFO] --- maven-compiler-plugin:2.0.2:compile(默认)   @scala.maven.test --- [INFO]无需编译 - 所有类都已启动   到目前为止[INFO] [INFO] --- maven-resources-plugin:2.4.3:testResources   (default-testResources)@scala.maven.test --- [警告]使用   平台编码(实际上是Cp1252)来复制过滤后的资源,即   构建依赖于平台! [INFO]复制0资源[INFO] [INFO]   --- maven-scala-plugin:2.9.1:testCompile(scala-test-compile)@scala.maven.test --- [ERROR]   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ test \ java [错误]   C:\ workspaces \ 29112012 \ scala.maven.test \ src \ test \ java .. \ scala [INFO]   将1个源文件编译为   C:\ workspaces \ 29112012 \ scala.maven.test \ target \ test-classes [INFO]   [INFO] --- maven-compiler-plugin:2.0.2:testCompile   (default-testCompile)@scala.maven.test --- [INFO]无需编译    - 所有类都是最新的[INFO] [INFO] --- maven-surefire-plugin:2.7.1:test(default-test)@scala.maven.test ---   [INFO] Surefire报告目录:   C:\工作空间\ 29112012 \ scala.maven.test \目标\万无一失的报告

     

----------------------------------------------- --------测试   -------------------------------------------------- -----没有测试可以运行。

     

结果:

     

测试运行:0,失败:0,错误:0,跳过:0

     

[INFO]   -------------------------------------------------- ---------------------- [INFO]建立成功[信息]   -------------------------------------------------- ---------------------- [INFO]总时间:11.354s [INFO]完成于:11月30日星期五16:57:05 GMT

     

2012 [INFO]最终记忆:7M / 17M [INFO]

这是我的pom.xml:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>scala.maven.test</groupId>
  <artifactId>scala.maven.test</artifactId>
  <version>0.0.1-SNAPSHOT</version>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.scala-tools</groupId>
                    <artifactId>maven-scala-plugin</artifactId>
                    <version>2.9.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.0.2</version>
                </plugin>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>
                                            org.scala-tools
                                        </groupId>
                                        <artifactId>
                                            maven-scala-plugin
                                        </artifactId>
                                        <versionRange>
                                            [2.9.1,)
                                        </versionRange>
                                        <goals>
                                            <goal>add-source</goal>
                                            <goal>compile</goal>
                                            <goal>testCompile</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.scala-tools</groupId>
                <artifactId>maven-scala-plugin</artifactId>
                <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>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

<dependencies>
  <dependency>
    <groupId>org.scalatest</groupId>
    <artifactId>scalatest_2.9.0-1</artifactId>
    <version>2.0.M5</version>
</dependency>
<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.11</version>
</dependency>
</dependencies>



</project>

2 个答案:

答案 0 :(得分:1)

尽管这是一个很晚的答复,但是我写它希望有人可以从中受益,以防他们的scala单元测试没有被发现。导致考试失败的主要途径之一是无声无息。如果路径上任何目录的名称中都有空格,则scalatest不会选择它。重命名此类目录以成功运行单元测试。

答案 1 :(得分:0)

您的测试类名称是什么? Maven可能非常挑剔,默认情况下我认为它要求类名以'Test'结尾。

见我的帖子: Maven won't run tests