这是我需要的:
- 必须能够在 Jenkins 中运行测试
- 我想测试 API,所以我不太关心函数和对象,我只是想确保当我将 POST 发送到/api/users.json 时,我会在 GET 的 json 数组中看到该用户/api/用户/.
有什么方法可以在同一个进程中运行应用和测试?
UPD。
问题已经解决了一半:我已经使用 mocha + should + reSTLer 来测试我的应用程序。这是工作。但是如何设置 jenkins 来运行这些测试呢?
最佳答案
自由式作业 -> 执行 shell 脚本 ->
npm install
node run.js &
node_pid=$!
sleep 15 // so tests won't fail because server not yet started
./node_modules/.bin/mocha --reporter tap > results/s-api.tap
result=$?
kill $node_pid
sleep 1 // so jenkins won't "scream" about leaked process
return result // we need return code of tests
关于rest - Express.js 的 BDD 测试框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9458396/