Maven没有运行我的testng.xml [英] Maven doesn't run my testng.xml
问题描述
当我通过testng.xml运行时(右键单击testng.xml,然后以TestNG运行),它可以正常工作-我已经在其中进行了2个测试,但是当我从Maven中运行它时(mvn测试),它只是执行构建而不会运行测试. 顺便说一句-我注意到,如果我有带有单词Test的类,它们将默认在Maven上运行,但这对我不利,因为我需要能够通过testng.xml文件控制测试的能力.
When i'm running through testng.xml (right click on testng.xml, then run as TestNG) it works fine - 2 of the tests i have there are running, but when i'm running it from Maven (mvn test) it just perform build and doesn't run the tests. BTW - i noticed that if i have classes with the word Test in them they are running by default on Maven, but this is not good for me since i need the ability to control the tests through the testng.xml file.
这是我的pom.xml:
this is my 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>Group1</groupId>
<artifactId>artifact1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>artifact1</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-surefire-plugin -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20</version>
<type>maven-plugin</type>
</dependency>
</dependencies>
</project>
这是我的testng.xml:
This is my testng.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite guice-stage="DEVELOPMENT" name="GroupXdefault suite" verbose="0">
<test name="Default test" verbose ="1">
<classes>
<class name="Group1.artifact1.TC1" />
<class name="Group1.artifact1.TC2" />
</classes>
</test> <!-- Default test -->
</suite> <!-- Default suite -->
推荐答案
是否可以删除配置文件并尝试使用构建插件
Can you just remove profile and try with build plugin
这篇关于Maven没有运行我的testng.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!