> For the complete documentation index, see [llms.txt](https://tdd.shujuwajue.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tdd.shujuwajue.com/ju-ti-shi-jian-1/dui-wei-fu-wu-api-de-shi-jian.md).

# 对微服务Api的实践

## 资料

[Test-Driven-Development for building APIs in Node.js and Express](https://developers.redhat.com/blog/2016/03/15/test-driven-development-for-building-apis-in-node-js-and-express/)

说明：针对的express框架如何开展tdd的步骤。

* 指出从如何从功能测试(集成测试)，引出单元测试（function函数测试）
* 示例代码：<https://github.com/cianclarke/tdd-for-apis>

[Testing Node and Express](https://mherman.org/blog/testing-node-and-express/)

说明：使用express的crud操作阐述tdd过程。

* 同样提到了功能测试(集成测试)和单元测试（function函数测试）
* 提出了一个很好的解决测试数据的问题,自动生成：[faker.js](https://github.com/marak/Faker.js/)
* 示例代码：<https://github.com/mjhea0/express-testing-mocha-knex>

[Test Driven Development with Node, Postgres, and Knex (Red/Green/Refactor)](https://mherman.org/blog/test-driven-development-with-node/)

说明：详细使用Red/Green/Refactor的原则的crud操作阐述tdd过程。

* 字段全校验
* 示例代码：<https://github.com/mjhea0/mocha-chai-knex>

## 其他参考：

[BDD/TDD development from scratch with node.js/express](https://www.robotlovesyou.com/bdd-tdd/)

[Building Node.js REST API with Express.js, MongoDB & TDD – Tutorial](https://www.novicedeveloper.com/building-nodejs-rest-api-expressjs-mongodb-tdd/)

[TDD: Testing NodeJS and React with Mocha, Chai, Sinon and Enzyme](http://www.darrenbeck.co.uk/react/testing/testing-part1/)

[ Node Express TDD with RESTful API in Intellij](http://www.whiteboardcoder.com/2015/04/node-express-tdd-with-restful-api-in.html)

[Test-driven Development of Node.js APIs](https://www.sphereinc.com/test-driven-development-of-node-js-apis/)

[Express Routes: A TDD Approach](https://medium.com/@jodylecompte/express-routes-a-tdd-approach-1e12a0799352)

[Using Test-Driven Development for Microservices](https://nordicapis.com/using-test-driven-development-for-microservices/)　（Lex）

![](https://2056388194-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfwIC9s9ctw6bxuGRce%2F-LgejT8vu0Jem6HF0TnI%2F-LgejdsVRFn8dja7RfdT%2Fimage.png?alt=media\&token=8d3fe102-3b55-4c06-be01-1cd7bb90231b)

![](https://2056388194-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfwIC9s9ctw6bxuGRce%2F-LgekjZniSHvmQzhwvwj%2F-LgekkjU0QrIhdSjw31t%2Fimage.png?alt=media\&token=8d786e6a-fe10-408f-bfa6-323518faba98)

![](https://2056388194-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfwIC9s9ctw6bxuGRce%2F-LgekEI7SFIbSgDhzqfm%2F-LgekQbYkJK4-e4dRx92%2Fimage.png?alt=media\&token=2795376e-9823-4b29-a94c-82e97bbec2b6)

![](https://2056388194-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfwIC9s9ctw6bxuGRce%2F-LgekEI7SFIbSgDhzqfm%2F-LgekFiE_xP9bHuuVijH%2Fimage.png?alt=media\&token=f11234f3-25cd-4138-85df-48cb15481a0f)

![](https://2056388194-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LfwIC9s9ctw6bxuGRce%2F-Lgek0_6A_MvZWo8eJKP%2F-Lgek1rO0i3toOrMV9pj%2Fimage.png?alt=media\&token=2a266aec-b2df-40f1-8478-9c153c73f770)
