MVN TestNG的无法运行测试套件,而想法可以 [英] mvn testng can't run test suite while Idea can

查看:726
本文介绍了MVN TestNG的无法运行测试套件,而想法可以的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个TestNG的套件看起来像这样

I have a testNg suite looking like this

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="BlahServerSuite">
    <test name="Creating Customer Test">
        <classes>
        <class name="com.node.service.scripts.server.CustomerTest" />
        </classes>
    </test>
</suite>

它运行正常,当我从IDE中运行它。但是,当我试图从MVN测试控制台执行它我有以下错误:

It runs normally when I run it from IDE. But when I am trying execute it from console with "mvn test" I have following error:

  [TestNGClassFinder] Warning: Can't link and determine methods of class com.node.service.scripts.server.CustomerTest

我的POM看起来是这样的:

My pom looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<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>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19.1</version>
                <configuration>
                        <suiteXmlFiles>
                            <suiteXmlFile>src/testNode/java/com/testnode/service/scripts/server/serversuite.xml</suiteXmlFile>
                        </suiteXmlFiles>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <groupId>groupId</groupId>
    <artifactId>testNode</artifactId>
    <version>1.0-SNAPSHOT</version>
    <dependencies>
    ....

该项目由几个模块。尽管POM文件位于modul2(以及测试),我还需要设置完整路径,在POM套件文件,否则MVN没有看到测试套件的。
什么可能是这里的情况和方式,我应该看?

The project consists from several modules. Even though pom file is located in modul2(as well as tests), i still need to set full path for the suite file in pom, otherwise mvn doesn't see test suite at all. What might be the case here and which way should I look?

推荐答案

这可能是这样,您使用的是非标准的位置测试源。它仍然可能在IDE工作,如果你在暗示一些设置添加他们。因此,尽量使用的src /测试来替代,或者尝试添加您的src / testNode 测试来源。你可以用例如做集结帮手 - Maven的插件。像这样:

It might be the case, that you're using non-standard location for test sources. It might still work in IDE, if you implicitly added them in some settings. So, try to use src/test instead, or try to add you src/testNode to test sources. You can do it with build-helper-maven-plugin for example. Like so:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-test-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/testNode</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

这篇关于MVN TestNG的无法运行测试套件,而想法可以的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆