线上第六期_接口测试用例管理与 Jenkins 结合_0728

有问题请回帖

参考

代码:https://github.com/seveniruby/RestAssuredDemo0728
Jenkins Job示例:http://jenkins.testing-studio.com:8081/job/RestAssured0729/

参考代码

mvn+junit案例

pom.xml

<?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>xueqiu.testerhome.com</groupId>
    <artifactId>api</artifactId>
    <version>1.0-SNAPSHOT</version>

    <dependencies>

        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>3.1.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

</project>

Base.java

package com.testerhome.api.junt;

import org.junit.*;

public class Base {
    @BeforeClass
    public static void beforeClass(){
        System.out.println("com.testerhome.api.junt.Base BeforeClass");
    }
    @AfterClass
    public static void afterClass(){
        System.out.println("com.testerhome.api.junt.Base AfterClass");
    }

    @Before
    public void setup(){
        System.out.println("setup");
    }

    @Test
    public void demo1(){
        System.out.println("demo1");
    }

    @Test
    public void demo0(){
        System.out.println("demo");
    }

    @Test
    public void demo2(){
        System.out.println("demo2");
    }

}


children.java

package com.testerhome.api.junt;

import org.junit.*;
import org.junit.experimental.categories.Category;
import org.junit.runners.MethodSorters;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Children extends Base{
    @BeforeClass
    public static void beforeClassChildren(){
        System.out.println("com.testerhome.api.junt.Children BeforeClass");
    }
    @AfterClass
    public static void afterClassChildren(){
        System.out.println("com.testerhome.api.junt.Children AfterClass");
    }

    @Before
    public void setupChildren(){
        System.out.println("setupChildren");
    }
    @Test
    @Category(Stage.class)
    public void demo1Children(){
        System.out.println("demo1Children");
    }

    @Test
    @Ignore("just for show")
    public void demo0Children(){
        System.out.println("demoChildren");
    }

    @Test
    @Category(Prod.class)
    public void demo2Children(){
        System.out.println("demo2Children");
    }

}

作业

使用继承方式的简单接口测试用例执行,可以在Jenkins上运行起来。把自己的代码github地址发到回复里。

关闭