LoginSignup
1
1

More than 5 years have passed since last update.

Codeceptionの形式 Cept・Cestの違いと覚え方

Last updated at Posted at 2016-12-23

Cept? Cest?

Codeceptionでテストをジェネレートするときに
generate:ceptgenerate:cestを選ぶことができる。

なんだか名前が似ていて、よくわからない・・・ということで、双方をジェネレートしてみる。

手元にないのでうろ覚えですが、codeceptionのバージョンは2系だったと思います。

Cept

$ php codecept.phar generate:cept api ceptSample

生成されたソース

ceptSample.php
<?php 
$I = new ApiTester($scenario);
$I->wantTo('perform actions and see result');

プレーンPHPが生成される

調べているとよく遭遇するwebguyというメソッドは、上記ソースのApiTesterにあたるよう。(codeception 1系だと、webguy?)

Cest

$ php codecept.phar generate:cest api cestSample

対してCestは、

cestSample.php
<?php
class cestSampleCest
{
    public function _before(ApiTester $I)
    {
    }

    public function _after(ApiTester $I)
    {
    }

    // tests
    public function tryToTest(ApiTester $I)
    {
    }
}

クラス化されている。

さいごに

公式リファレンスみたら書いてあるが、たびたび忘れるしよく打ち損じるので、

Cept の P は plain の P
Cest の S は simple の S

ということだけでもおぼえておきます。

1
1
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
1
1