Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unit testing MVN未找到测试_Unit Testing_Maven - Fatal编程技术网

Unit testing MVN未找到测试

Unit testing MVN未找到测试,unit-testing,maven,Unit Testing,Maven,当运行mvn clean install时,一旦我们到达测试部分,我就明白了 ------------------------------------------------------- T E S T S ------------------------------------------------------- Results : Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 我的surefire插件配置如下:

当运行
mvn clean install
时,一旦我们到达测试部分,我就明白了

-------------------------------------------------------
 T E S T S
-------------------------------------------------------

Results :

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
我的surefire插件配置如下:

        <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <testFailureIgnore>false</testFailureIgnore>
                <includes>
                    <include>**/*Test*.java</include>
                </includes>
            </configuration>
        </plugin>
单个测试用
@Test
注释,并且

import org.junit.Test; 
更多的测试名称遵循

public void testSomething() throws Exception
本着完整的精神,下面是我的pom

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <modelVersion>4.0.0</modelVersion>
    <groupId>a.b.c</groupId>
    <artifactId>My_Project</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <repositories>
        <repository>
            <id>JBOSS_NEXUS</id>
            <url>http://repository.jboss.org/nexus/content/groups/public</url>
        </repository>
    </repositories>
    <build>
        <finalName>My_Project</finalName>
        <plugins>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>1.7.4</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <extensions>false</extensions>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <vesion></vesion>
                <configuration>
                    <testFailureIgnore>false</testFailureIgnore>
                    <includes>
                        <include>**/*Test*.java</include>
                    </includes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <formats>
                        <format>xml</format>
                        <format>html</format>
                    </formats>
                    <check/>
                </configuration>
                <executions>
                    <execution>
                        <phase>clean</phase>
                        <goals>
                            <goal>cobertura</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <reporting>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>cobertura-maven-plugin</artifactId>
                <version>2.5.1</version>
            </plugin>
        </plugins>
    </reporting>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.8.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            ...
        </dependency>
    </dependencies>
</project>

4.0.0
a、 不列颠哥伦比亚省
我的计划
1.0.0-SNAPSHOT
战争
JBOSS_NEXUS
http://repository.jboss.org/nexus/content/groups/public
我的计划
com.google.appengine
appengine maven插件
1.7.4
maven战争插件
2.1.1
假的
假的
maven编译器插件
2.3.2
1.6
1.6
UTF-8
maven surefire插件
假的
**/*Test*.java
org.codehaus.mojo
cobertura maven插件
2.5.1
xml
html
清洁的
科贝图拉
org.codehaus.mojo
cobertura maven插件
2.5.1
朱尼特
朱尼特
4.8.2
测试
...

请问我遗漏了什么?

如果信息像现在这样分散,那就很难帮上忙了。你可能无法或不想透露更多信息,因此我们必须与我们所看到的进行合作

与我通常的代码不同的是,
test

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>

请包含未找到的小测试的来源。它们是如何注释的?您使用的是什么测试框架?@DaveNewton更新了问题我觉得您的
模式可能是原因。请尝试删除此部分,并查看是否运行了任何测试。@AndrewLogvinov尝试过,似乎没有帮助。您可以发布pom.xml文件吗?看来我们需要全面考虑一下。另外,请查看构建输出。是否编译了测试?我尝试了上面列出的所有步骤,同样的问题。。还可能是什么?尝试使用mvn-X获得额外的诊断,并尝试单独运行一个测试(查看maven文档了解如何执行)。您还可以尝试使用Netbeans打开/重新创建您的项目,看看IDE是否能给您任何提示。
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>