LoginSignup
9
8

More than 5 years have passed since last update.

PHPUnit、Seleniumでエンドツーエンドテスト

Last updated at Posted at 2015-10-16

以前Railsではこんな感じでテストしてたけどPHP案件だし、PHPでエンドツーエンドテスト書くかーってなってちょっと試してみたメモです。

Composerまではインストールしてある想定で話を進めます。

composer.json
"require-dev": {
    "phpunit/phpunit": "4.8.*",
    "phpunit/phpunit-selenium": ">=1.2"
  }

phpunitコマンドを使うためにパスを通す。

export PATH=$PATH:~/.composer/vendor/bin/

パスが通っているかどうかを確認。

phpunit --version

テスト!

login.php

class Login extends PHPUnit_Extensions_Selenium2TestCase
{

  public function setUp()
  {
    $this->setBrowser('firefox');
    $this->setBrowserUrl('http://example.com');
  }

  public function testOpenLoginForm()
  {
    $this->url('http://www.example.com/');
    $this->assertEquals('ログイン画面', $this->title());
  }

}

実行!

phpunit login.php

とりあえず動かすまで^^;

参考

https://phpunit.de/manual/3.7/ja/selenium.html
http://qiita.com/Butackle/items/61d932af17ccc1557fe8

9
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8