Edw*_*uay 4 php phpunit kohana
我正在用PHPUnit编写单元测试.
我现在有大约100种方法.
由于这些是用于Kohana框架应用程序,我也使用它的命名约定来测试方法,例如:
function test_instance()
{
...
}
function test_config()
{
...
}
Run Code Online (Sandbox Code Playgroud)
我的所有测试都在Eclipse和命令行中运行良好.
但是,我现在需要使用一个setup函数,并意识到它只在命名时才有效:
function setUp()
{
...
}
Run Code Online (Sandbox Code Playgroud)
并不是:
function set_up()
{
...
}
Run Code Online (Sandbox Code Playgroud)
现在我想知道如果我不重命名我所有的PHPUnit方法以便它们是驼峰的话,我是否会有任何不利之处,例如,使用PHPUnit的其他工具除了方法名称是否为camelcase表示法?
Gor*_*don 12
PHP中的方法名称不区分大小写,因此使用setup
or setUp
和tearDown
or 无关紧要teardown
.但是,您可能不会使用set_up
或tear_down
,因为这是一个不同的名称.PHPUnit调用setUp
并tearDown
在每次测试之间保证环境.
按照惯例,PHPUnit会将任何以方法开头的方法视为test
Test.您可以使用@test
方法DocBlock中的注释来省略前缀.在打印任何报告时,PHPUnit会将CamelCased方法名称转换为间隔描述,因此testMethodDoesThis
将显示为"Method Does This".
CamelCase还会影响使用@testDox
注释注释的测试.
归档时间: |
|
查看次数: |
1367 次 |
最近记录: |