简体   繁体   English

Maven Surefire找不到测试

[英]Maven Surefire does not find tests

I am having difficulties with maven surefire, as it does not run my tests. 我在使用maven surefire时遇到困难,因为它无法运行我的测试。 I know this question has been asked many times before and I have tried out multiple things all without success 我知道这个问题已经被问过很多次了,我尝试了很多事情都没有成功

  1. I changed the name of my test directory to src/test/java 我将测试目录的名称更改为src / test / java
  2. I changed the names of my test to fit the *Test pattern 我更改了测试名称以适合* Test模式
  3. I tried a Junit3 test 我尝试过Junit3测试
  4. I tried specifically including a test in the pom 我尝试过专门在pom中进行测试

Maybe anyone of you can point out my probably stupid mistake. 也许你们每个人都可以指出我可能是愚蠢的错误。

My pom is listed below 我的pom列在下面

<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>BitTrader</groupId>
    <artifactId>BitTrader</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>BitTrader</name>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <sonar.language>java</sonar.language>
        <sonar.jdbc.url>
            jdbc:h2:tcp://lustigsbusi.ch:9092/sonar
        </sonar.jdbc.url>
        <sonar.host.url>
            http://lustigsbusi.ch:9000
        </sonar.host.url>
    </properties>
    <build>
        <!-- To define the plugin version in your parent POM -->
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sonar-maven-plugin</artifactId>
                    <version>2.1</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sonar-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <source>1.7</source>
                    <target>1.7</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <includes>
                        <include>CombinedOrderBookTest.java</include>
                    </includes>
                </configuration>

            </plugin>
        </plugins>
    </build>
    <repositories>

    </repositories>
    <dependencies>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>14.0.1</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty</artifactId>
            <version>3.6.6.Final</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat-coyote</artifactId>
            <version>7.0.41</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>1.3.2</version>
        </dependency>
        <dependency>
            <groupId>net.sf.opencsv</groupId>
            <artifactId>opencsv</artifactId>
            <version>2.3</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-core</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-examples</artifactId>
            <version>1.8.0</version>
            <exclusions>
                <exclusion>
                    <artifactId>logback-classic</artifactId>
                    <groupId>ch.qos.logback</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>logback-core</artifactId>
                    <groupId>ch.qos.logback</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-bitcoincharts</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-bitstamp</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-btce</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-campbx</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-cavirtex</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-mtgox</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.xeiam.xchange</groupId>
            <artifactId>xchange-openexchangerates</artifactId>
            <version>1.8.0</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
        </dependency>
    </dependencies>
</project>

EDIT It works with Dtest. 编辑它与Dtest一起使用。

This is the output of mvn test http://pastebin.com/bZ9Mg4Bs 这是mvn test http://pastebin.com/bZ9Mg4Bs的输出

If your test-class follows the naming convention, then there's no need to specify the includes. 如果您的测试类遵循命名约定,则无需指定包含。

The real issue is that it seems like 'CombinedOrderBookTest.java' can't be matched. 真正的问题在于,似乎无法匹配“ CombinedOrderBookTest.java”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM