51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 1579|回复: 3
打印 上一主题 下一主题

[求助] 有没有什么方法能把 excel 里写的接口测试用例通过代码自动生成

[复制链接]
  • TA的每日心情
    无聊
    2024-7-12 13:16
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    跳转到指定楼层
    1#
    发表于 2017-6-15 15:56:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
    而不是一个接口写一个test开头的方法
    1. <span class="nd">@allure.feature</span><span class="p">(</span><span class="s">'注册'</span><span class="p">)</span>
    2. <span class="nd">@pytest.mark.parametrize</span><span class="p">(</span><span class="s">'realCode, realMessage, expeCode, expeMessage, testCaseName'</span><span class="p">,</span> <span class="n">ResultParam</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
    3. <span class="k">def</span> <span class="nf">test_register</span><span class="p">(</span><span class="n">realCode</span><span class="p">,</span> <span class="n">realMessage</span><span class="p">,</span> <span class="n">expeCode</span><span class="p">,</span> <span class="n">expeMessage</span><span class="p">,</span> <span class="n">testCaseName</span><span class="p">):</span>
    4.      <span class="k">assert</span> <span class="n">realCode</span> <span class="o">==</span> <span class="n">expeCode</span>
    5.      <span class="k">assert</span> <span class="n">realMessage</span> <span class="o">==</span> <span class="n">expeMessage</span>
    6.     <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">testCaseName</span><span class="p">)</span>


    7. <span class="nd">@allure.feature</span><span class="p">(</span><span class="s">'登录'</span><span class="p">)</span>
    8. <span class="nd">@pytest.mark.parametrize</span><span class="p">(</span><span class="s">'realCode, realMessage, expeCode, expeMessage, testCaseName'</span><span class="p">,</span> <span class="n">ResultParam</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
    9. <span class="k">def</span> <span class="nf">test_login</span><span class="p">(</span><span class="n">realCode</span><span class="p">,</span> <span class="n">realMessage</span><span class="p">,</span> <span class="n">expeCode</span><span class="p">,</span> <span class="n">expeMessage</span><span class="p">,</span> <span class="n">testCaseName</span><span class="p">):</span>
    10.      <span class="k">assert</span> <span class="n">realCode</span> <span class="o">==</span> <span class="n">expeCode</span>
    11.      <span class="k">assert</span> <span class="n">realMessage</span> <span class="o">==</span> <span class="n">expeMessage</span>
    12.      <span class="n">logging</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">testCaseName</span><span class="p">)</span>
    复制代码


    分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
    收藏收藏
    回复

    使用道具 举报

    该用户从未签到

    2#
    发表于 2017-6-15 16:05:51 | 只看该作者
    用Apache POI 获取excel。
    回复 支持 反对

    使用道具 举报

  • TA的每日心情
    无聊
    2024-7-12 13:16
  • 签到天数: 1 天

    连续签到: 1 天

    [LV.1]测试小兵

    3#
     楼主| 发表于 2017-6-15 16:06:23 | 只看该作者
    草帽路飞UU 发表于 2017-6-15 16:05
    用Apache POI 获取excel。

    嗯,谢谢了!
    回复 支持 反对

    使用道具 举报

    本版积分规则

    关闭

    站长推荐上一条 /1 下一条

    小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

    GMT+8, 2024-11-11 05:55 , Processed in 0.062290 second(s), 23 queries .

    Powered by Discuz! X3.2

    © 2001-2024 Comsenz Inc.

    快速回复 返回顶部 返回列表