基于jenkins的自动化单元测试实践

来源:互联网 发布:浩方对战平台mac版 编辑:程序博客网 时间:2024/05/22 02:28

一、 单元测试并生成报告
1、maven插件

<reporting>    <plugins>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-surefire-report-plugin</artifactId>            <version>2.4.2</version>        </plugin>    </plugins></reporting>

2、jenkins配置

构建脚本: mvn clean surefire-report:report配置报告:

这里写图片描述
配置报告的另一种方式是讲生成的html报告 集成到jenkins中;这需要jenkins的Publish HTML reports 插件,安装插件后 在 job中配置如下:
这里写图片描述
定时检查代码,是否有新的提交,执行jenkins job:这里写图片描述

二、 Findbugs
1、maven 插件

<reporting>    <plugins>        <plugin>            <groupId>org.codehaus.mojo</groupId>            <artifactId>findbugs-maven-plugin</artifactId>            <version>3.0.1</version>            <configuration>                <xmlOutput>true</xmlOutput>                <!-- Optional directoryto put findbugs xdoc xml report -->                <!--<xmlOutputDirectory>target/site</xmlOutputDirectory>-->                <findbugsXmlOutput>true</findbugsXmlOutput>                <findbugsXmlWithMessages>true</findbugsXmlWithMessages>            </configuration>        </plugin>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-surefire-report-plugin</artifactId>            <version>2.4.2</version>        </plugin>    </plugins></reporting>

2、jenkins配置

安装 jenkins的 Findbugs插件构建脚本:mvn clean surefire-report:report findbugs:findbugs配置报告:

这里写图片描述

三、 PMD 静态代码检查

1、maven 插件

<reporting>    <plugins>        <plugin>            <groupId>org.codehaus.mojo</groupId>            <artifactId>findbugs-maven-plugin</artifactId>            <version>3.0.1</version>            <configuration>                <xmlOutput>true</xmlOutput>                <!-- Optional directoryto put findbugs xdoc xml report -->                <!--<xmlOutputDirectory>target/site</xmlOutputDirectory>-->                <findbugsXmlOutput>true</findbugsXmlOutput>                <findbugsXmlWithMessages>true</findbugsXmlWithMessages>            </configuration>        </plugin>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-pmd-plugin</artifactId>            <version>3.0.1</version>        </plugin>        <plugin>            <groupId>org.apache.maven.plugins</groupId>            <artifactId>maven-surefire-report-plugin</artifactId>            <version>2.4.2</version>        </plugin>    </plugins></reporting>

2、jenkins 配置

构建脚本:mvn clean surefire-report:report findbugs:findbugs pmd:pmd报告配置:

这里写图片描述

阅读全文
0 0
原创粉丝点击