V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
KeatingSmith
V2EX  ›  问与答

请教:后端模拟数据方法

  •  
  •   KeatingSmith · 2018-10-09 09:40:06 +08:00 · 1430 次点击
    这是一个创建于 1998 天前的主题,其中的信息可能已经有所发展或是发生改变。

    现在使用的是 MySQL,但是测试的时候没啥数据。

    因此,想问下各位,作为后端,怎么模拟 MySQL 数据进行测试呢?

    9 条回复    2018-10-09 11:02:48 +08:00
    wysnylc
        1
    wysnylc  
       2018-10-09 09:57:49 +08:00
    insert
    Mazexal
        2
    Mazexal  
       2018-10-09 10:00:51 +08:00
    直接 mock 返回结果, 数据?不存在的
    x66
        3
    x66  
       2018-10-09 10:03:49 +08:00 via iPhone
    最方便的是 Mock,如果后端先开发的话,自测的时候就插入一些数据进去吧
    gaius
        4
    gaius  
       2018-10-09 10:04:03 +08:00
    mock
    loveCoding
        5
    loveCoding  
       2018-10-09 10:15:14 +08:00
    Mockito,powermock
    KeatingSmith
        6
    KeatingSmith  
    OP
       2018-10-09 10:26:10 +08:00
    @x66

    就是插入时数据挺麻烦的,想了解一下有没有自动化工具。
    Mutoo
        7
    Mutoo  
       2018-10-09 10:30:08 +08:00
    搜索一下 Database Seeding 有专门的工具做这件事
    Faker https://github.com/fzaninotto/Faker
    xiaoxinshiwo
        8
    xiaoxinshiwo  
       2018-10-09 10:54:06 +08:00
    先把插入接口做好
    reus
        9
    reus  
       2018-10-09 11:02:48 +08:00
    你不测试数据插入的?
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5686 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 01:45 · PVG 09:45 · LAX 18:45 · JFK 21:45
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.