INNOBASE技術ブログ

技術的なことエンジニア的なこと制作的なこと全般

FuelPHP (oil) でファイル指定でユニットテストを行う方法 + oilのメモ

結論:oilでファイル指定でユニットテストを行う方法

php oil test --file=fuel/app/tests/********.php

↑このコマンドでファイル指定のユニットテストが実行できます。

結論を見つけるまでの過程

読み飛ばし可…oilのhelpのみかたとか実態の場所とかのメモです。

  • phpunit 生で使っている時に使っている方法(file pathを単純に引数で渡す)で動かなかった…
  • php oil help 実行
********** Custom Oil **********

Usage:
  php oil [cell|console|generate|package|refine|help|server|test]

Runtime options:
  -f, [--force]    # Overwrite files that already exist
  -s, [--skip]     # Skip files that already exist
  -q, [--quiet]    # Supress status output
  -t, [--speak]    # Speak errors in a robot voice

Description:
  The 'oil' command can be used in several ways to facilitate quick development, help with
  testing your application and for running Tasks.

Environment:
  If you want to specify a specific environment oil has to run in, overload the environment
  variable on the commandline: FUEL_ENV=staging php oil <commands>

More information:
  You can pass the parameter "help" to each of the defined command to get information
  about that specific command: php oil package help

Documentation:
  http://docs.fuelphp.com/packages/oil/intro.html

※↓ここに注目、コマンドに続けて help を打てば良いと

More information:
  You can pass the parameter "help" to each of the defined command to get information
  about that specific command: php oil package help
  • php oil test help 実行
Usage:
  php oil [t|test]

Runtime options:
  --file=<file>              # Run a test on a specific file only.
  --group=<group>            # Only runs tests from the specified group(s).
  --exclude-group=<group>    # Exclude tests from the specified group(s).
  --testsuite=<testsuite>    # Only runs tests from the specified testsuite(s).
  --coverage-clover=<file>   # Generate code coverage report in Clover XML format.
  --coverage-html=<dir>      # Generate code coverage report in HTML format.
  --coverage-php=<file>      # Serialize PHP_CodeCoverage object to file.
  --coverage-text=<file>     # Generate code coverage report in text format.
  --log-junit=<file>         # Generate report of test execution in JUnit XML format to file.
  --debug                    # Display debugging information during test execution.

Description:
  Run phpunit on all or a subset of tests defined for the current application.

Examples:
  php oil test

Documentation:
  http://fuelphp.com/docs/packages/oil/test.html


* --file で引数渡せば良いと…解決!
* ※見て分かるようにHP 上にちゃんとドキュメントあります。 http://fuelphp.com/docs/packages/oil/test.html

oil test の処理の実態の場所

* fuel/app/classes/oil/classes/command.php ←この辺りに処理が書いてあります。
* task (refine)と同じノリで1ファイル切ってあると勘違いしていました(^_^;)

oil refine help で定義したtaskの一覧が見える

php oil refine help

help の動作確認していたところ、task一覧が見えることがわかってきました。
地味に便利ですね!