API Testing - TDD for APIs

Test-Driven Development (TDD) is a software development paradigm used very commonly in production. Often this is done via pair programming. It is based on a short, rapid development cycle in which tests are written before the executable code and constantly iterated on.

  1. Write Test for specific application behavior.
    • What is the expected behavior?
    • Do you expect errors?
    • What are the pieces of that response?
    • What assumptions are you making?
  2. Fail Test and watch them
    (You want to see that failure happen before you’ve written the code itself so that you know your application is failing the test and that the test is well formatted.)
  3. Write Code to execute the required behavior
  4. Pass Test
  5. Refactor
    (You want to make sure the code that you have written, is as efficient as humanly possible.)
  6. Repeat 1-5 steps for the next test

Often while pair programming, one partner will write the test and the other will write the executable code, after which the partner will switch. This process is helpful for checking assumptions about behavior and making sure all expected behavior is captured.


The benefit of doing TDD:

  • Define expected behavior before implementation
  • Write concise code that just executes the behavior
  • Keeps development cycles short and rapid
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值