Maven运行testNG case

1: 创建testng.xml配置文件

1.1:生成testng.xml配置文件

右键项目-->testNG--->Convert to TestNG

1.2:选择要运行的类方法

2:Maven插件的导入

2.1:查看maven版本

maven版本为3.5.4

2.2:根据版本在pom.xml中导入依赖 

maven版本是3.5.4 所以这里写3.5就可以了 JDK版本我这里用的是1.7

2.3:导入TestNG的依赖

<dependency>
    <groupId>org.testng</groupId>
    <artifactId>testng</artifactId>
    <version>6.14.3</version>
    <scope>test</scope>
</dependency>

2.4:根据testNG版本导入maven-surefire-plugin插件

2.5:导入的plugins

	<build>
		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.5</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.20</version>
				<configuration>
					<suiteXmlFiles>
						<suiteXmlFile>testng.xml</suiteXmlFile>
					</suiteXmlFiles>
				</configuration>
			</plugin>
		</plugins>

	</build>

2.7:右击pom.xml-->run as-->maven test运行

猜你喜欢

转载自blog.csdn.net/hujyhfwfh2/article/details/81433333
今日推荐