Sometimesit isjust plain hard to test the system under test (SUT) becauseit depends on other components that cannot be used in the test environment. This could be because they aren't available, they will not return the results needed for the test or because executing them would have undesirable side effects. In other cases, our test strategy requires us to have more control or visibility of the
みなさんこんにちは。@ryuzeeです。 Behatは良さそうなので引き続き検証しています。 今回は、BehatとSeleniumを組み合わせて、受け入れテスト型のテストを自動化してみたので、その方法について説明しましょう。 なお、前回の記事を読まれていない場合はまずそちらを参照してください。PHPでBDD(Behavior Driven Development)する方法 Seleniumの課題僕が関わっている案件では受入テストを自動化しているケースももちろんあって、その際はPHPUnitとSeleniumを組み合わせています。 このテストには以下のような課題があります。 画面の操作をするphpコードが大量にあって、ソースを見ただけでは何をしているのか分かりにくいSeleniumは操作に画面の要素名利用するため、例えばサイトのデザインを大幅に変えたりすると、テストの中身も大幅に書き換えな

Sebastian Bergmann hascreated the industry-leading testing toolPHPUnit, which has played a vital role in professionalizing software development withPHP. Sebastian shares his comprehensive experience in publications and at conferences. As Co-Founder and Principal Consultant of ThePHP Consulting Company (thePHP.cc), he helps his clients to develop software successfully. In his free time, Sebasti
Symfony Advent Calendar JP 2011の3日目の記事です。 みなさん、Symfony2本体のソースコードやテストコードを読んだことはありますか? Symfony2本体は、コアコンポーネント、コアバンドル等で成り立っており、それぞれ独立したテストコードが付属しています。PHPUnitのモックオブジェクト等を使ったテストがふんだんにあり、レイヤー化されたコンポーネントのテスト方法の参考になります。 今回は、Symfony Componentの中核をなす「HttpKernel」コンポーネントの中の、Kernelクラスのテストを1つ見てみましょう。 tests/Symfony/Tests/Component/HttpKernel/KernelTest.php: <?php // snip namespace Symfony\Tests\Component\HttpKerne
TDD Boot Camp(Tokyo 2013-03)にphp(PHPUnit)で参加してきました。主催者・TA、会場の株式会社VOYAGE GROUP 8F 社内バー AJITOに感謝です。 勉強会 行きたい行きたいと1年くらい思ってからの勉強会でした。勉強会の温度はtwitterや発表資料などで感じでいましたが、参加してみて目の前にいる人がその人の声で聞くと、勉強に対するモチベーションはだいぶ高くなりました。 ポジションペーパー 受付をすませた後にポジションペーパーのテンプレートをもらいました。以下のような項目を埋めました。 名前 k_somemo ペアプログラミング経験 なし TDD経験 あり 言語php テスティングフレームワークPHPUnit エディタ・IDE Eclipse キーボード配列 日本語 ペアプロデモ @yattomさんと@grimroseさんによるFizzBu
PHPでテストを書くというとPHPUnitがデファクトスタンダードで、次がSimpleTestでしょうか。 以前はインストールも大変でしたが、今となってはcomposer使えば楽ですし、実績もあります。 でも、本当にこの2択でPHPらしい開発ができていますか? たとえば、テストケースのクラスを用意することが前提になります。 ちょっとPHPのコードを書いてテストしたいときもです。 たとえば、以下のようなロジックを書きたいとします。 <?php $users = [ '太郎' => 'male', '花子' => 'female', '一郎' => 'male', ]; // この$usersから男性('male')のものだけを抽出したい $males = [ '太郎' => 'male', '一郎' => 'male', ]; ?> 普通にPHPUnitでTDDでとなると、それなりに面倒です
![[PHP] Hamcrestを利用した超シンプルdocコメントでのテスト方法 - ぷぎがぽぎ](/image.pl?url=https%3a%2f%2fcdn-ak-scissors.b.st-hatena.com%2fimage%2fsquare%2f284e2dc427bd4f3ba9341b37cf9ec416e8f06bbc%2fheight%3d288%3bversion%3d1%3bwidth%3d512%2fhttps%253A%252F%252Fcdn.image.st-hatena.com%252Fimage%252Fscale%252Fd19c4c5b992817ff551d0bcb9db131013404b725%252Fbackend%253Dimagemagick%253Bversion%253D1%253Bwidth%253D1300%252Fhttps%25253A%25252F%25252Fcdn-ak.f.st-hatena.com%25252Fimages%25252Ffotolife%25252Fb%25252FbrtRiver%25252F20130317%25252F20130317145007.png&f=jpg&w=240)
Welcome! I assume that you came to this website looking for information on how to implement Continuous Integration (CI) and Continuous Delivery (CD) pipelines forPHP projects with Jenkins. Back in 2010, Icreated an Open Sourcetemplate for Jenkins jobs forPHP projects and this website used to be the home of that project. I have neither used Jenkins nor updated the aforementionedtemplate in qui
最近になってPHPUnitをちゃんと使ってユニットテストを書くようになってきたのですが、まだまだTipsが足りないと感じます。個人的に実践している書き方をいくつか並べてみます。 追記:最初、シェバングと書いていましたが、オプションを渡せる数が決まっていたりOSによっては動かなかったりとあまり便利でないことがわかりました。。phpunit.xmlを書いた方がいいかも。 ちょっとしたテスト → シェルスクリプト化するPHPUnitは高機能なのですが、いかんせん最初の障壁が高いと思います。とにかく気軽に書きたいなら、シェルスクリプトを作って単独ファイルで実行できるようにするといいです。 #!/bin/shphpunit --colors *Test.php # ↑オプションを書き並べておく <?php class SampleTest extendsPHPUnit_Framework_Te

皆さん, ユニットテスト書いてますか. TDD (テスト駆動開発) によるプログラミングは本当に楽しいものですが, コマンドをいちいち手動で実行するのは面倒ですよね. テストを自動化しているんだから, その実行も自動化したいですよね. この記事では, 私が仕事や趣味で使っているPHPUnit を例に, テストの実行の自動化について紹介します.PHPUnit の, としてはいますが, 他の言語で使えるテクニックもあります. なお, ここでの自動化は開発しながらの自動実行のことで, CI (継続的インテグレーション) の話は出てきません. その前に... 私の開発時のターミナルは以下のようになっています. [caption id="attachment_1298" align="alignnone" width="300" caption="開発時のターミナル"][/caption] GN

There are two styles of testing: "black box" and "white box" styles.Black box testing focuses on the object's state; whereas, white box testing focuses on behavior. The two styles complement each other and can be combined to thoroughly test code. Mocking allows us to test behavior, and this tutorial combines the mocking concept with TDD tobuild an example class that uses several other components

classTwitterClient { public function tweet($message) { return true; } } $hoge = newTwitterClient(); $hoge->tweet('大心なう'); // trueが返る class ClientContainerTest extendsPHPUnit_Framework_TestCase { public function test_モックを書いてみる() { $hoge = $this->getMock('TwitterClient', array('tweet')); $hoge->expects($this->any()) ->method('tweet') ->will($this->returnValue(true)); $hoge->tweet('大心なう'); // true

ちまたで人気の Composer を試してみた。 http://getcomposer.org/ だが、pear 経由ではPHPUnit がインストールに失敗する。もしかしたら Composer の不具合かもしれないが、どうやらPHPUnit のpear の管理情報 (packages.json) に問題(?)があるらしい。 https://gist.github.com/2433139 を参考にして、インストールしてみた。 composer.json: リポジトリをローカル指定し、url の先にPHPUnit 用の packages.json を配置する。 { "repositories" : [ { "type" : "composer", "url" : "file:///path/to/repositories/phpunit" } ], "require" : { "pea
April 21, 2014PHPUnit was developed in cvs.php.net and released on pear.php.net fromits inception in 2001 until July 2006.PHPUnit was developed in svn.phpunit.de from July 2006 until December 2009 whenits development moved toGitHub. Until today, everyPHPUnit release was made available as a PEAR package. These PEAR packages were hosted on pear.phpunit.de since July 2006. SincePHPUnit 3.7, re

リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く