Skip to content

CSVのテストに失敗したとき、失敗した理由を出力する #61

@yasulab

Description

@yasulab

背景

Travis CI でテスト結果を見たとき、 Name should be lower case みたいなメッセージが出るべきかなと思っているのですが、次のようなメッセージがテスト結果として出力されていると、テストコードが間違っている可能性を考えてしまう (し、どこを直せばよいのかがパッと見てわからない)。なので、失敗した理由が Travis CI 上で出力されるようにしたい。

CIで失敗した場合の出力例: https://travis-ci.org/coderdojo-japan/dojopaas/builds/270670168

> [email protected] test:csv /home/travis/build/coderdojo-japan/dojopaas
> node test/test-csv.js
assert.js:81
  throw new assert.AssertionError({
  ^
AssertionError: true deepEqual false
    at /home/travis/build/coderdojo-japan/dojopaas/test/test-csv.js:12:12
    at tryToString (fs.js:449:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:436:12)
npm ERR! Linux 4.11.6-041106-generic
npm ERR! argv "/home/travis/.nvm/versions/node/v7.10.1/bin/node" "/home/travis/.nvm/versions/node/v7.10.1/bin/npm" "run" "test:csv"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test:csv: `node test/test-csv.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] test:csv script 'node test/test-csv.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the dojopaas package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node test/test-csv.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs dojopaas
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls dojopaas
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR!     /home/travis/.npm/_logs/2017-09-01T02_49_32_886Z-debug.log
The command "npm run test:csv" exited with 1.
Done. Your build exited with 1.

実装案

テストは完全に独立しているので、適宜必要なテストを追加すれば良さそう。JSでも良いし、Rubyでも良い。

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions