Robotframework(4)-使用FakerLibrary生成随机测试数据

1、安装:pip install -U robotframework-faker
在这里插入图片描述
2、在testSuite中设置引入FakerLibrary(设置参数zn-CN表示生成中文数据)
在这里插入图片描述
3、在用例中使用关键字

    #性名相关
    ${test1}    name    #人名
    ${test2}    last name    #姓氏
    ${test2}    ssn    #身份证号
    #地理位置相关
    ${test1}    country    #国家
    ${test1}    province    #省份
    ${test1}    city name    #市
    ${test1}    address    #完整地址
    ${fakeLongitude}    Longitude    #随机生成经度
    ${fakeLatitude}    Latitude    #随机生成纬度
    ${test1}    postcode    #邮编
    #职场相关    company
    ${test1}    company    #公司名
    ${test1}    company suffix    #公司性质
    ${test1}    email    #邮箱
    ${test1}    image url    #图片地址
    ${test1}    ipv4    #ipv4地址
    ${test1}    year    #年份
    ${test1}    sentence    #随机句子

4、运行结果如下

20200206 17:11:19.575 :  INFO : ${test1} = 周成
20200206 17:11:19.576 :  INFO : ${test2} = 李
20200206 17:11:19.577 :  INFO : ${test2} = 513333198806163611
20200206 17:11:19.578 :  INFO : ${test1} = 特立尼达和多巴哥
20200206 17:11:19.579 :  INFO : ${test1} = 上海市
20200206 17:11:19.579 :  INFO : ${test1} = 天津
20200206 17:11:19.580 :  INFO : ${test1} = 黑龙江省鑫市西峰巢湖街z座 185980
20200206 17:11:19.581 :  INFO : ${fakeLongitude} = -150.240261
20200206 17:11:19.581 :  INFO : ${fakeLatitude} = 18.132418
20200206 17:11:19.582 :  INFO : ${test1} = 844725
20200206 17:11:19.582 :  INFO : ${test1} = 和泰科技有限公司
20200206 17:11:19.583 :  INFO : ${test1} = 科技有限公司
20200206 17:11:19.583 :  INFO : ${test1} = [email protected]
20200206 17:11:19.584 :  INFO : ${test1} = https://placekitten.com/65/479
20200206 17:11:19.596 :  INFO : ${test1} = 188.208.207.55
20200206 17:11:19.597 :  INFO : ${test1} = 1984
20200206 17:11:19.598 :  INFO : ${test1} = 历史所有上海这么查看工作.
发布了107 篇原创文章 · 获赞 10 · 访问量 9658

猜你喜欢

转载自blog.csdn.net/liying15/article/details/104198912
今日推荐