惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
云风的 BLOG
云风的 BLOG
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
P
Palo Alto Networks Blog
D
Docker
H
Hackread – Cybersecurity News, Data Breaches, AI and More
S
Schneier on Security
Engineering at Meta
Engineering at Meta
I
InfoQ
L
LangChain Blog
Cyberwarzone
Cyberwarzone
T
Tenable Blog
WordPress大学
WordPress大学
P
Privacy & Cybersecurity Law Blog
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Jina AI
Jina AI
C
CERT Recently Published Vulnerability Notes
Scott Helme
Scott Helme
博客园 - 三生石上(FineUI控件)
酷 壳 – CoolShell
酷 壳 – CoolShell
Know Your Adversary
Know Your Adversary
D
Darknet – Hacking Tools, Hacker News & Cyber Security
The Last Watchdog
The Last Watchdog
Last Week in AI
Last Week in AI
Cloudbric
Cloudbric
S
SegmentFault 最新的问题
爱范儿
爱范儿
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 叶小钗
AI
AI
T
Tor Project blog
I
Intezer
T
Threatpost
www.infosecurity-magazine.com
www.infosecurity-magazine.com
V
Visual Studio Blog
N
News and Events Feed by Topic
Latest news
Latest news
S
Security Affairs
博客园 - Franky
Microsoft Security Blog
Microsoft Security Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
B
Blog RSS Feed
C
Cybersecurity and Infrastructure Security Agency CISA
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
S
Securelist

博客园 - happy刘艺

关于SKILL idea解压包安装问题解决 转载:java :: Java中的双冒号操作符 转:Git的使用--如何将本地项目上传到Github(两种简单、方便的方法) 转:springboot 与swagger整合出现Unable to infer base url.This is common when using dynamic的解决办法 转:Swagger2自动生成接口文档和Mock模拟数据 InfluxDB springboot application.properties文件加载顺序 spring-boot项目学习路径 collection 与stream与lambd表达式的结合使用 转:Java中Lambda表达式的使用 RPC之Thrift 介绍及java实例 class对象的getResource()方法 Eclipse开发,编译,打包常见问题总结------持续更新 mysql查找包含某个字符串的记录 性能测试入门(零)测试前言 性能测试入门(八)jmeter--PerfMon(性能监控工具)插件安装与部署 jmeter--PerfMon(性能监控工具)插件使用详解 性能测试入门(七)jmeter分布式测试
maven surefire插件与testng
happy刘艺 · 2019-06-12 · via 博客园 - happy刘艺

总结就是:参考文章:https://www.jianshu.com/p/2594dcbd3272

Maven surefire插件是一个执行maven项目测试代码的插件。

Maven本身并不是一个单元测试框架,Java世界中主流的单元测试框架为JUnit和TestNG。Maven所做的只是在构建执行到特定生命周期阶段的时候,通过插件来执行JUnit或者TestNG的测试用例。这一插件就是maven-surefire-plugin,可以称之为测试运行器(Test Runner),他能很好的兼容JUnit 3、JUnit 4以及TestNG。

我们知道,生命周期阶段需要绑定到某个插件的目标才能完成真正的工作,test阶段正是maven-surefire-plugin的test目标相绑定了,这是一个内置的绑定。

1、maven-surefire-plugin插件默认会自动执行测试源码包(即test目录下)中遵循以下命名规则的java测试类。(有文章说如果测试method不是以test*开头,就不会执行到该测试方法。应该指的是没有做任何自定义configuration配置的默认情况下)

  1. **/Test*.java
  2. **/*Test.java
  3. **/*TestCase.java

对应的pom.xml

<build>

        <plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-surefire-plugin</artifactId>

                <version>2.19</version>

                <configuration>

                    <encoding>UTF-8</encoding>

                    <!--  <suiteXmlFiles>

                        <suiteXmlFile>TestNG.xml</suiteXmlFile>

                    </suiteXmlFiles>-->

                    <test>Order*.java</test><!-- test命令默认执行test目录下的文件 -->

                    <systemPropertyVariables>

                        <ddg.sys.name>htl_hse</ddg.sys.name>

                        <!-- <maven.surefire.debug>true</maven.surefire.debug> -->

                    </systemPropertyVariables>

                </configuration>

            </plugin>

</plugins>

</build>

2、也可以通过指定<suiteXmlFiles>属性来运行t指定的testng.xml执行测试套

(将< suiteXmlFile>的value值设置为引用properties,则更灵活。执行命令时就可以指定想这些的testng.xml eg:mvn clean test -DsuiteXmlFile=src/test/resources/xml/a.xml)

对应的pom.xml

<properties>

        <suiteXmlFile>testng.xml</suiteXmlFile>

    </properties>

<plugins>

            <plugin>

                <groupId>org.apache.maven.plugins</groupId>

                <artifactId>maven-surefire-plugin</artifactId>

                <version>2.19</version>

                <configuration>

                    <encoding>UTF-8</encoding>

                    <suiteXmlFiles>

                        <suiteXmlFile>${suiteXmlFile}</suiteXmlFile>

                    </suiteXmlFiles>

                </configuration>

            </plugin>

</plugins>

3、更多surefire plugin的使用方法可以通过maven-help-plugin插件查看当前测试插件绑定的生命周期
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-surefire-plugin:2.7 -Ddetail

mvn surefire:help -Ddetail=true -Dgoal=test