一提到web自动化框架/工具,很多同行会想起: watir等。其实PHP的世界一样很精彩,流行PHP测试框架phpunit、simpletest、PHP-QAT 。PHP-QAT 能做单元测试、web应用测试等。
1 下载安装
http://downloads.php.net/johannes/php-5.3.0alpha1.tar.gz
安装php: ./configure;make
在当前目录有run-tests.php。
2 环境设置
export TEST_PHP_EXECUTABLE=/usr/local/bin/php
3 样例
$ cd /usr/local/apache2/php-5.3.0alpha1
$ ./run-tests.php xyz/001.phpt
=====================================================================
PHP : /usr/local/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.3.0alpha1
ZEND_VERSION: 2.3.0
PHP_OS : Linux - Linux alitest146 2.6.9-42.ELsmp #1 SMP Wed Jul 12 23:27:17 EDT 2006 i686
INI actual : /usr/local/apache2/php-5.3.0alpha1
More .INIs :
CWD : /usr/local/apache2/php-5.3.0alpha1
Extra dirs :
VALGRIND : Not used
=====================================================================
Running selected tests.
b user is /usr/local/apache2/php-5.3.0alpha1/xyz/001.phpt Array/usr/local/apache2/php-5.3.0alpha1/xyz/001.phpt is fileTEST 1/1 [xyPASS Simple POST Method test [xyz/001.phpt]
=====================================================================
Number of tests : 1 1
Tests skipped : 0 ( 0.0%) --------
Tests warned : 0 ( 0.0%) ( 0.0%)
Tests failed : 0 ( 0.0%) ( 0.0%)
Expected fail : 0 ( 0.0%) ( 0.0%)
Tests passed : 1 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken : 0 seconds
=====================================================================
[root@alitest146 /usr/local/apache2/php-5.3.0alpha1]
$ cat xyz/001.phpt
--TEST--
Simple POST Method test
--SKIPIF--
<?php if (php_sapi_name()=='cli') echo 'skip'; ?>
--POST--
a=Hello+World
--FILE--
<?php
echo $_POST['a']; ?>
--EXPECT--
Hello World
4更多详细信息参考 http://qa.php.net/write-test.php
文章来源于领测软件测试网 https://www.ltesting.net/