SlowPasswordHasherのテスト(Travis CIためす準備)
はじめに
Travis CIというものを試してみたいのです。
GitHubにコミットされたソースコードを取得してビルド、テストしてくれるものらしいです。
たぶんテストされるのとテストするのがないと試してもよくわからないので
まず、先日のSlowPasswordHasher.phpのユニットテストを作ります。
テスト作成
\app\Test\Case\Controller\Component\AuthにSlowPasswordHasherTest.php作成して
コミットします。
<?php App::uses('SlowPasswordHasher', 'Controller/Component/Auth'); /** * Class SlowPasswordHasherTest */ class SlowPasswordHasherTest extends CakeTestCase { public function setUp() { parent::setUp(); $this->passwordHasher = new SlowPasswordHasher(); } public function testMatchPassword() { $rawPassword = 'p@ssword21'; $hashed = $this->passwordHasher->hash($rawPassword); $this->assertTrue($this->passwordHasher->check($rawPassword, $hashed)); } public function testUnmatchPassword() { $rawPassword = 'p@ssword21'; $missPassword = 'p@ssword22'; $hashed = $this->passwordHasher->hash($missPassword); $this->assertFalse($this->passwordHasher->check($rawPassword, $hashed)); } }
テストはグリーンです。
Travis CI
GitHubにコミットしたらTravis CIと連携してみます。
「https://travis-ci.org/」の「Sign in with Github」リンクを押すと
勝手にビルドされましたがFailedです。
Could not find .travis.yml, using standard configuration.
たぶん、.travis.ymlにどんなテストやら解析するのかいろいろ書いてあげるんだと思われますが
時間切れなので明日やってみます。
継続的デリバリー 信頼できるソフトウェアリリースのためのビルド・テスト・デプロイメントの自動化
- 作者: David Farley,Jez Humble,和智右桂,高木正弘
- 出版社/メーカー: アスキー・メディアワークス
- 発売日: 2012/03/14
- メディア: 大型本
- 購入: 24人 クリック: 567回
- この商品を含むブログ (51件) を見る