maven运行testng的pom文件

maven官方文档

http://maven.apache.org/plugins/index.html

在pom.xml文件中增加testng的maven dependencies,可以选择最新版本.可以去以下的网站搜索最新版本的maven库

search.maven.org
image.png

maven给testng提供了3个插件用于扩展:resource、compile、surefire

在pom文件中引用testng.xml,使用surefire插件;引用compile插件可以解决编码、编译器版本问题

<?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>

    <groupId>TestngDemo</groupId>
    <artifactId>TestngDemo</artifactId>
    <version>1.0-SNAPSHOT</version>
    <properties>
        <!--解决编码问题-->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.testng/testng -->
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.11</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <verbose>true</verbose>
                    <!--在新的虚拟机中开启-->
                    <fork>true</fork>
                    <compilerVersion>1.8</compilerVersion>
                    <encoding>utf-8</encoding>
                    <!--源代码的编译-->
                    <source>1.8</source>
                    <target>1.8</target>

                </configuration>

                </plugin>
                <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.20</version>
                <configuration>
                    <suiteXmlFiles>
                        <!--可以添加多个xml文件-->
                        <file>testng.xml</file>
                    </suiteXmlFiles>

                    <properties>
                        <property>

                            <!--日志级别,0-10,10最详细-->
                            <name>surefire.testng.verbose</name>
                            <value>5</value>
                            <!--允许并行-->
                            <name>suitethreadpoolsize</name>
                            <value>2</value>
                            
                        </property>
                    </properties>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

修改编码格式,使用resource插件。官网给出两种方案,最好的是在pom文件中增加<properties>,还有一个是在<bulid><plugins><plugin><configuration><encoding>UTF-8<...

image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 136,644评论 19 139
  • Spring Boot 参考指南 介绍 转载自:https://www.gitbook.com/book/qbgb...
    毛宇鹏阅读 47,279评论 6 342
  • Maven简单介绍 Maven是一个项目管理工具。强大,但是很容易使用。 它包含了: 一个项目对象模型 (Proj...
    高公子Daniel阅读 4,505评论 4 60
  • 我们都知道Maven本质上是一个插件框架,它的核心并不执行任何具体的构建任务,所有这些任务都交给插件来完成,例如编...
    付鹏丶阅读 1,691评论 0 15
  • 所有项目的构建都是有生命周期的,这个生命周期包括:项目清理、初始化、编译、测试、打包、集成测试、验证、部署、站点生...
    zlcook阅读 3,008评论 0 21

友情链接更多精彩内容