KeatingSmith
V2EX  ›  问与答

请教:后端模拟数据方法

  •  
  •   KeatingSmith · Oct 9, 2018 · 1877 views
    This topic created in 2802 days ago, the information mentioned may be changed or developed.

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

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

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

    就是插入时数据挺麻烦的,想了解一下有没有自动化工具。
    Mutoo
        7
    Mutoo  
       Oct 9, 2018
    搜索一下 Database Seeding 有专门的工具做这件事
    Faker https://github.com/fzaninotto/Faker
    xiaoxinshiwo
        8
    xiaoxinshiwo  
       Oct 9, 2018
    先把插入接口做好
    reus
        9
    reus  
       Oct 9, 2018
    你不测试数据插入的?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1255 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 510ms · UTC 23:41 · PVG 07:41 · LAX 16:41 · JFK 19:41
    ♥ Do have faith in what you're doing.