Testman
2012.11.24 PyFes
Success

                           Fail

rhacoのキャラクターを書いてくれる人を募集するために書いたダサいカエルの絵が会社のJenkinsで
使われています。rhacoのテストはxUnit形式のxmlを出力していなくてjenkinsが使えない。同僚は仕
方なくphpUnitを使おうとしたようですが…
phpUnitが全く気に入らず、結果の保存や、カバレッジ含んだ画面を見られるTestmanを開発してし
まいました。わたしは再度ダサキャラを…。OSSもゆるキャラ時代になるに違いないっす。
• curl -L -O 
    https://github.com/downloads/tokushima/
    testman/testman.php




   http://localhost/testman.php/web/index.php




Testmanはファイル一つ。ブラウザで表示できる。使い方のドキュメントも含んでいる。
• php testman.php -report




xDebugを有効にして、reportオプション付きでテストを実行すれば、カバレッジ確認できる。
• php testman.php -report




詳細でマウスオーバーすれば、どのファイルでカバーされているかもわかる。
test client
       • https://github.com/tokushima/
         testman/blob/master/example/test/
         entry/top.php

     <?php
     eq(1,1);

     $b = b();
     $b->do_get(test_map_url('top','HOGE','AAA'));
     eq('TOP_HOGEAAA',$b->body());




URLの設定から逆引きして決定したURLに対してブラウザの振りをしたクライアントでのテストもでき
る。
doctest
            <?php
            class Sample{
              public function abc($str){
                return '('.$str.')';
                /∗∗∗
                 ∗ $self = new self();
                 ∗ eq("(hoge)",$self->abc("hoge"));
                 ∗/
                /∗∗∗
                  # fuga
                  $self = new self();
                  eq("(fuga)",$self->abc("fuga"));
                 ∗/
              }
              static public function def($str){
                return '('.$str.')';
                /∗∗∗
                  eq("(hoge)",self::def("hoge"));
                 ∗/
              }
              /∗∗∗
                eq("(hoge)",self::def("hoge"));
                $self = new self();
                eq("(fuga)",$self->abc("fuga"));
               ∗/
              
              /∗∗∗
                # __setup__
                eq(true,true);
               ∗/
              /∗∗∗
                # __teardown__
                eq(true,true);
               ∗/
            }



Pythonistaにはおなじみのdoctest。doctestなのにsetupとteardownがある。
https://github.com/tokushima/testman

Testman

  • 1.
  • 2.
    Success Fail rhacoのキャラクターを書いてくれる人を募集するために書いたダサいカエルの絵が会社のJenkinsで 使われています。rhacoのテストはxUnit形式のxmlを出力していなくてjenkinsが使えない。同僚は仕 方なくphpUnitを使おうとしたようですが…
  • 3.
  • 4.
    • curl -L-O https://github.com/downloads/tokushima/ testman/testman.php http://localhost/testman.php/web/index.php Testmanはファイル一つ。ブラウザで表示できる。使い方のドキュメントも含んでいる。
  • 5.
    • php testman.php-report xDebugを有効にして、reportオプション付きでテストを実行すれば、カバレッジ確認できる。
  • 6.
    • php testman.php-report 詳細でマウスオーバーすれば、どのファイルでカバーされているかもわかる。
  • 7.
    test client • https://github.com/tokushima/ testman/blob/master/example/test/ entry/top.php <?php eq(1,1); $b = b(); $b->do_get(test_map_url('top','HOGE','AAA')); eq('TOP_HOGEAAA',$b->body()); URLの設定から逆引きして決定したURLに対してブラウザの振りをしたクライアントでのテストもでき る。
  • 8.
    doctest <?php class Sample{   public function abc($str){     return '('.$str.')';     /∗∗∗      ∗ $self = new self();      ∗ eq("(hoge)",$self->abc("hoge"));      ∗/     /∗∗∗       # fuga       $self = new self();       eq("(fuga)",$self->abc("fuga"));      ∗/   }   static public function def($str){     return '('.$str.')';     /∗∗∗       eq("(hoge)",self::def("hoge"));      ∗/   }   /∗∗∗     eq("(hoge)",self::def("hoge"));     $self = new self();     eq("(fuga)",$self->abc("fuga"));    ∗/      /∗∗∗     # __setup__     eq(true,true);    ∗/   /∗∗∗     # __teardown__     eq(true,true);    ∗/ } Pythonistaにはおなじみのdoctest。doctestなのにsetupとteardownがある。
  • 9.