3:JavaAppium 数据中心的搭建及使用

5 篇文章 1 订阅
5 篇文章 1 订阅

在日常测试过程中,测试数据的准备占用了测试人员很大的精力。如果您处于学习阶段可以使用:https://test.igood.wang作者提供的数据中心,进行学习。如果您当前处于生产环境,建议您搭建私有数据中心。
>数据中心使用

1:数据模板的声明
```language
package wang.igood.example.data;

import wang.igood.test.base.data.APIData;
import java.io.Serializable;

@APIData(code = "DySearchcKey",name = "抖音关键字",description = "用于抖音搜索")
public class DySearchcKey implements Serializable {

    @APIData(title = "关键字")
    private String searcchKey;

    public String getSearcchKey() {
        return searcchKey;
    }

    public void setSearcchKey(String searcchKey) {
        this.searcchKey = searcchKey;
    }

    @Override
    public String toString() {
        return "DySearchcKey{" +
                "searcchKey='" + searcchKey + '\'' +
                '}';
    }
}
```
APIData是数据模板声明时使用的注解,变量注解中title对应着excel表中的表头

2:数据模板的注册
```language
import wang.igood.example.data.DySearchcKey;
import wang.igood.test.base.Bootstrap;
import wang.igood.test.base.data.APIDataCenter;

import java.io.InputStream;


public class Application extends Bootstrap{

    //系统初始化app
    @Override
    public void init() {
        InputStream io = ClassLoader.getSystemResourceAsStream("app.properties");
        initConfig(io);
    }

    //注册数据模板
    @Override
    public void register() {
        APIDataCenter.getShareInstance().register(DySearchcKey.class);
        APIDataCenter.getShareInstance().upload();
    }
}
```
测试用例运行前会触发数据注册,只需要您在register中添加注册代码
```language
APIDataCenter.getShareInstance().register(DySearchcKey.class);
```
3:测试数据准备

![image.png](https://upload-images.jianshu.io/upload_images/20018861-f036373f9489b47b.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Excel表的方式存储,表头对应着数据模板中的title

4:测试数据的导入
![image.png](https://upload-images.jianshu.io/upload_images/20018861-2e45223c3172072e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

5:测试数据的获取

```language
 DySearchcKey key = (DySearchcKey) APIDataCenter.getShareInstance().getData(DySearchcKey.class);

```

6:Demo下载地址:https://igood.oss-cn-beijing.aliyuncs.com/DYExample.zip

>数据中心的搭建

[数据中心地址](https://igood.oss-cn-beijing.aliyuncs.com/JavaAppium%E6%95%B0%E6%8D%AE%E4%B8%AD%E5%BF%83.zip)

压缩包中包含两部分 TestWeb-1.3-SNAPSHOT.war(WEB项目文件),db_auto_test.sql(数据库初始化文件)
第一步:创建Mysql数据库,并通过db_auto_test.sql初始化数据库
第二步:在Tomcat中部署JavaWeb项目,修改/WEB-INF/classes/application.properties 文件
```language
url=jdbc:mysql://数据库地址:数据库端口/数据库名?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&autoReconnectForPools=true&useSSL=false
driverClassName=com.mysql.jdbc.Driver
username=数据库用户名
password=数据库密码
```
第三步:启动项目

http://项目地址:端口  
![image.png](https://upload-images.jianshu.io/upload_images/20018861-99d54945f1acb025.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)

显示该图片是就部署成功了。
>本人诚接各类商业化App自动化测试工作,如果您是一家公司,想借助自动化测试解决当前服务问题,可以联系我。微信号:CompanyAiHelper  

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值