这是我需要的:
- 必须能够在 Jenkins 中运行测试
- 我想测试 API,所以我并不关心函数和对象,我只想确保当我将 POST 发送到 /api/users.json 时,我会在 GET /api/ 的 json 数组中看到该用户用户/。
有什么方法可以在同一进程中运行应用程序和测试?
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