restAssure-接口自动化项目搭建

背景:
以下步骤是根据开发给我搭建好的自动化项目,复刻出来,至于为什么这样做,,我还在慢慢研究
场景:
项目接口自动化,能够在gocd上自动运行
一、项目搭建
1、创建项目gradle
2、删掉mian(可删可不删,只是基本没用)
3、修改为intelliJ IDEA在这里插入图片描述
4、build.gradle文件添加所需要的依赖,并加载

dependencies {

    //jackson
    implementation 'com.fasterxml.jackson.core:jackson-core:2.9.8'
//    implementation 'com.fasterxml.jackson.core:jackson-core:2.11.2'
    implementation 'com.fasterxml.jackson.core:jackson-annotations:2.9.8'
    implementation 'com.fasterxml.jackson.core:jackson-databind:2.9.8'
//    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.0'
    implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8'

    //hutool
    implementation group: 'cn.hutool', name: 'hutool-all', version: '5.8.15'

    //lang3
    implementation 'org.apache.commons:commons-lang3:3.12.0'

    //obs
    implementation 'com.huaweicloud:esdk-obs-java-bundle:3.22.3'

    //lombok
    testCompileOnly 'org.projectlombok:lombok'
    testAnnotationProcessor 'org.projectlombok:lombok'

    //jdbc
    testImplementation 'org.springframework.boot:spring-boot-starter-jdbc'

    //test
    testImplementation 'org.springframework.boot:spring-boot-starter-test'

    testImplementation 'io.rest-assured:rest-assured:4.5.1'
    testImplementation 'io.rest-assured:json-path:4.5.1'
    testImplementation 'io.rest-assured:xml-path:4.5.1'

    testImplementation 'com.alibaba:fastjson:1.1.54.android'

    //DBRider
    testImplementation 'com.github.database-rider:rider-core:1.32.3'
    testImplementation 'com.github.database-rider:rider-junit5:1.32.3'
    testImplementation 'com.github.database-rider:rider-spring:1.32.3'

    //excel
    testImplementation 'com.alibaba:easyexcel:3.0.5'

    //mockito
    testImplementation 'org.mockito:mockito-inline:4.9.0'
}

5、在test-java下创建项目包com.***,并在该目录下添加springBootApplication启动文件
在这里插入图片描述
二、配置环境
需要配置的:url,切换环境

1、切换环境:添加环境配置文件,dev表示当前使用application-dev的配置文件,有多个环境,写多个环境的application-**即可
在这里插入图片描述

application-dev中配置环境url,数据库等环境相关内容
在这里插入图片描述

2、配置URL,RestAssured.baseURI默认是本机

表示取带有“env”的值,此处能取dev环境中的yml中的dev的url
在这里插入图片描述
取url,并在接口调用中拼接
在这里插入图片描述
3、获取token
登录接口获取token,后续可以直接用asDev()
在这里插入图片描述
使用举例:
在这里插入图片描述

  • 7
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值