wangzilun
2021-12-15 3ea0a617c945a224a89ae0212fa108c5c96b8793
引入maven测试
2 files modified
2 files added
65 ■■■■■ changed files
.gitignore 5 ●●●● patch | view | raw | blame | history
Jenkinsfile 11 ●●●●● patch | view | raw | blame | history
src/pom.xml 39 ●●●●● patch | view | raw | blame | history
src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java 10 ●●●●● patch | view | raw | blame | history
.gitignore
@@ -11,4 +11,7 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.idea/
gitflow-installer.sh
gitflow-installer.sh
target/
**/target/
*.iml
Jenkinsfile
@@ -10,6 +10,7 @@
        }
    options {
        //给日志加上时间错, 需安装 Timestamper 插件
        //mvn test surefire-report:report
        timestamps()
        ansiColor('xterm')
        //丢弃旧的构建前两个为发布包保留天数(比此早的发布包将被删除,但构建的日志、操作历史、报告等将被保留)和构建个数
@@ -29,7 +30,15 @@
            }
        }
        stage('test') {
        stage('testMaven') {
            steps {
                sh 'mvn clean test -U'
                junit allowEmptyResults: true, keepLongStdio: true, skipPublishingChecks: true, testResults: 'target/surefire-reports/*.xml'
            }
        }
        stage('testFunction') {
            steps {
                sh '''
src/pom.xml
New file
@@ -0,0 +1,39 @@
<?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>com.hbbohua</groupId>
    <artifactId>git_study</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
src/test/java/com/hbbohua/gitStudy/HelloWorldTest.java
New file
@@ -0,0 +1,10 @@
package com.hbbohua.gitStudy;
import org.junit.Test;
public class HelloWorldTest {
    @Test
    public void test1(){
        System.out.println("hello test....");
    }
}