站长百科 | 数字化技能提升教程 数字化时代生存宝典
首页
数字化百科
电子书
建站程序
开发
服务器
办公软件
开发教程
服务器教程
软件使用教程
运营教程
热门电子书
WordPress教程
宝塔面板教程
CSS教程
Shopify教程
导航
程序频道
推广频道
网赚频道
人物频道
网站程序
网页制作
云计算
服务器
CMS
论坛
网店
虚拟主机
cPanel
网址导航
WIKI使用导航
WIKI首页
最新资讯
网站程序
站长人物
页面分类
使用帮助
编辑测试
创建条目
网站地图
站长百科导航
站长百科
主机侦探
IDCtalk云说
跨境电商导航
WordPress啦
站长专题
网站推广
网站程序
网站赚钱
虚拟主机
cPanel
网址导航专题
云计算
微博营销
虚拟主机管理系统
开放平台
WIKI程序与应用
美国十大主机
编辑“
WordPress:Automated Testing
”
人物百科
|
营销百科
|
网赚百科
|
站长工具
|
网站程序
|
域名主机
|
互联网公司
|
分类索引
跳转至:
导航
、
搜索
警告:
您没有登录。如果您做出任意编辑,您的IP地址将会公开可见。如果您
登录
或
创建
一个账户,您的编辑将归属于您的用户名,且将享受其他好处。
反垃圾检查。
不要
加入这个!
= Automated testing = = 自动化测试 = Automated Testing is the act of running all or some test cases in an environment, where each individual test is run one after the other and combining the results. There are different ways to create automated testing suites and even then automated does not have to apply to a system where it is run without you manually starting it. Automated only means that it will run all of the test cases for you without you having to run each one by yourself. 自动化测试指的是在一个环境中运行所有的或者某些测试,每个单独的测试都是一个接着一个地运行,然后将测试结果综合起来。创建自动化测试suites,有不同的方式,而且即使是自动化的,也不用应用到一个不需要你手动使其开始的系统。自动化只是指会为你运行所有的test cases,不需要你自己一个一个地运行这些test cases。 The [http://svn.automattic.com/wordpress-tests/ Automattic WordPress Tests] is the formal and authoritative automated testing suite for WordPress. The only way to download is by checking out with Subversion and there isn't a bug tracker devoted to just it. [http://svn.automattic.com/wordpress-tests/ 自动化 WordPress 测试]是关于WordPress的正式的,权威的自动化测试suite。下面这个自动化测试的唯一方法就是,checking out with 子版本,而且没有专用的程序错误追踪器to just it。 There is also another tool, based on the Automattic WordPress Tests, called [http://wptests.dragonu.net WPTests], which allows for looking at the results based on its server configuration. The [http://wordpress.svn.dragonu.net/WPTests WPTests Respository] also can only be downloaded by Subversion. 以自动化WordPress测试为基础,还有一个工具,称作[http://wptests.dragonu.net WPTests],允许根据服务器配置,查看结果。[http://wordpress.svn.dragonu.net/WPTests WPTests 资源库]也只能够通过子版本下载。 The test case type that the Automattic WordPress Tests uses are not units, therefore mocks do not need to be made. This allows for testing the entire scope of a test in the WordPress execution, much like it would work on a live web site. It should be noted that you should not run the Automattic WordPress Tests on a web site you don't want to be deleted. The Automattic WordPress Tests will remove all databases before and after it runs the tests, have a database devoted to just it. WordPress自动测试使用的test case类型并不是units,因此不需要制作mocks。这使得能够在WordPress中测试整个范围,就如在一个运行的站点上运行。应该注意你不能够在一个你不想要删除的站点上运行Automattic WordPress测试。WordPress自动测试会在测试之前和之后,移除所有的数据库,使用一个专门的数据库。 This section is composed of four parts: 这个部分有四个小部分组成: # Working with the Automattic WordPress Tests # 运行 Automattic WordPress Tests # Working with the WPTests Repository and Site # 运行 WPTests 知识库和站点 # Writing Test Cases #编写测试Cases # Submitting the Test Cases # 递交测试Cases = Automattic WordPress Tests = = Automattic WordPress Tests = == Downloading == == 下载 == You will need to download [[WordPress:Subversion]] before you can continue, if you don't have it already. You should also have an empty MySQL database available. Create a new one if you have to, but you don't want anything in there. 如果你还没有准备子版本,你需要下载[[WordPress:Subversion|子版本]]才能够继续运行。你还要有个空的MySQL数据库。如果需要的话,可以创建一个新的MySQL数据库,但是数据库中不应该包含内容。 Check out the latest testing suite from http://svn.automattic.com/wordpress-tests/ Check out http://svn.automattic.com/wordpress-tests/中最新的testing suite == Configuration == == 配置 == # In the root folder of the checkout copy wp-config-sample.php to wp-config.php. #在checkout的根文件夹中,将wp-config-sample.php复制到wp-config.php。 # Edit it to include your database name/user/password. #编辑这个,包含上你的数据库名/用户/密码。 You might find it easier to just go to that WordPress installation and run the install, so that it creates the wp-config for you. After, you can copy that to the directory below and run the tests. The Automattic WordPress Tests will be looking for wp-config.php in the same directory as wp-test.php. This will also prevent an error in which wp-cron.php will fail, because it can't find wp-config.php in that directory. 你可能发现直接进入WordPress安装并且运行安装,更简单,能够为你创建wp-config。然后,你可以将wp-config复制到下面的目录中并且运行测试。WordPress自动化测试会查找与wp-test.php在同一个目录的wp-config.php。这也会避免了wp-cron.php失败时候,可能出现的错误,因为不能在那个目录中找到wp-config.php。 == Running The Tests == == 运行测试 == The wp-test.php will initiate the automated test suite run. There are some options for which to control what tests are run and other options which trigger how the automated test suite works. Without any arguments, all tests will be run with default options. wp-test.php会将运行的自动化测试suite初始化。有些选项可以控制运行哪个测试,还有一些选项关于自动化测试suite是怎样运行的。没有任何参数的情况下,所有的测试会使用默认选项运行。 The average time for running all of the tests can range between 2 minutes and 7 minutes. This is with the current 399 test cases. When the amount increases, so will the time it will fully take to execute all of the tests. 运行所有测试的平均时间从2分钟到7分钟不等,这是关于当前399 test cases。当test cases数量增加的时候,运作所有测试的时间也会增加。 '''Note for Windows Users:''' The wp-test.php makes use of [http://www.php.net/getopt getopt()] function, which does not work on Windows before PHP 5.3. You will have to wait until PHP 5.3 comes out before you can use the command line on Windows or add some hacking to get it to work for you. ''' Windows 用户 应该注意:''' wp-test.php使用了[http://www.php.net/getopt getopt()]函数,这个函数在PHP5.3之前的Windows上不能够运行。你需要等待知道PHP5.3出现,你才能够在Windows上使用命令行或者添加一些hacking,使得函数能够运行。 Run the tests by typing: <tt>php wp-test.php</tt> in the command line. 通过在命令行中输入:<tt>php wp-test.php</tt>运行测试。 === Arguments === === 参数=== * -v : You can run WordPress Mu instead of WordPress, by typing <tt>php wptests.php -v mu</tt> * -v :通过输入<tt>php wptests.php -v mu</tt>,你可以运行WordPress MU而不是WordPress * -t : Choose which test you want to run, this is the class name, which is the test suite with the test cases. * -t :选择你想要运行哪个测试,这是class名称,是test cases的test suite。 * -r : The directory of WordPress which will be used to test. You may create custom patches on other locations and this allows you to not have to checkout multiple Automattic WordPress Tests repositories for which to apply those patches for testing. * -r :WordPress目录,将会用于测试。你可以在其它的地址上创建自定义补丁,这使你不用检查多个将补丁应用来测试的Automattic WordPress Tests知识库, * -s : If this option exists, then known WordPress bugs will be skipped. * -s :如果存在这个选项,那么会删除已知的WordPress程序错误。 * -f : If this option exists, then it will force skipping known WordPress bugs. * -f :如果存在这个选项,那么会迫使删除已知的WordPress程序错误。 The first three require a value to be after it, the last two only need to be typed. All arguments are optional. 前三个参数的后面需要加上一个值,后两个参数只需要输入即可。所有的参数都是可选择的。 === Examples === === 例子=== For example, if you wanted to run the Plugin API Actions test suite, then you would type the following on the command line: php wp-test.php -t WPTestActions 例如,如果你想要运行插件API Aciton 测试 suite,那么你需要在命令行中输入以下的内容: php wp-test.php -t WPTestActions If you wanted to skip known bugs, you would type the following: 如果你想要删除已知的程序错误,你需要输入以下的内容: php wp-test.php -s And if you wanted to force it: php wp-test.php -s -f php wp-test.php -s 如果你想要强迫删除程序错误,输入: php wp-test.php -s -f = WPTests Tool for Automattic WordPress Tests = = Automattic WordPress 测试的WP测试工具 = The [http://wptests.dragonu.net WPTests web site] is setup to automatically run two minutes past the hour, every hour. Therefore it provides a history starting from the 17th of March 2008 onward. This holds some interest to see where tests failures rose and fell. Given that it does not track the WordPress Subversion revisions, this doesn't hold that much strength other than to show which tests failed and what errors there were. 设置[http://wptests.dragonu.net WPTests 网站]是用来在每小时过两分钟之后,自动运行。因此,提供了从2008年3月17日开始向后的历史记录。看看测试是在哪里失败与成功的,非常有意思。假如,没有追踪WordPress子版本修订本,除了显示哪个测试失败了,出了什么错误之外,就不会显示其它更多的内容。 There are two parts to the WPTests Site. The Main page which shows the last available test run and how long ago it was. If it is longer than an hour and a half, then you know that something is wrong (given that if it was the web site, the entire web site would be down). WPTests站点有两个部分。主页显示了最近可以运行的测试和测试是什么时候开始的。如果测试时间超过了一个半小时,那么你知道出了什么问题(假如是整个网站,那么整个网站都会有问题)。 The second part is the historical test runs, which you can look through and some of the later test runs allow you to check the results of the run. 第二个部分是运行的测试的历史记录,你可以查看这些历史记录,最近运行的一些测试,能够使你查看测试运行的结果。 The repository is located at [http://wordpress.svn.dragonu.net/WPTests] and requires Subversion. 资源库位于[http://wordpress.svn.dragonu.net/WPTests]而且需要子版本。 Other requirements for running the WPTests tool on your system, is [http://www.wampserver.com/en/ WAMP], Apache, PHP, and MySQL. If you install the latest version of WAMP, then you'll have to enable PDO_SQLite module, because it is disabled by default and the tool needs it. 在你的系统上运行WPTests工具需要的其它条件,是[http://www.wampserver.com/en/ WAMP], Apache, PHP, and MySQL。如果你安装了最新版本的WAMP,那么你需要激活了PDO_SQLite模块,因为这个模块默认是关闭的,但是工具需要这个模块。 = Writing Tests = = 编写测试 = Test cases live in the <tt>wp-testcase</tt> subdirectory. All files in that directory will be included by default. Test cases位于<tt>wp-testcase</tt>子目录中。默认情况下,那个目录中的所有文件都包含其中。 Extend the WPTestCase class to ensure your test is run. You can see the code in current tests for examples or read the [http://www.phpunit.de/pocket_guide/3.0/en/ PHPUnit Pocket Guide]. 扩展WPTestCase class确保你的测试正在运行。例如你可以看看当前测试的代码或者阅读[http://www.phpunit.de/pocket_guide/3.0/en/ PHPUnit Pocket 指南]。 = Submitting the Test Cases = = 递交测试Cases = The test cases should be submitted to Alex Shiels of Automattic. You can [http://thresholdstate.com/contact/ contact him] at his blog or web site at Threshold State. You may also leave the test case at the WordPress Trac, if it is based on a ticket and inform Alex of the test case or test suite. 测试cases应该递交到Automattic的Alex Shiels。你可以在他的博客或者在Threshold State的网站上[http://thresholdstate.com/contact/ 联系他]。如果test case是以ticket或者test case or test suite的inform Alex为基础,你可以将test case放到WordPress Trac上。 Alex is fairly good at getting the test cases in within three to seven days. Alex在三到七天内能够将Alex收纳进来,这一点,Alexa做地很好。
摘要:
请注意,您对站长百科的所有贡献都可能被其他贡献者编辑,修改或删除。如果您不希望您的文字被任意修改和再散布,请不要提交。
您同时也要向我们保证您所提交的内容是您自己所作,或得自一个不受版权保护或相似自由的来源(参阅
Wordpress-mediawiki:版权
的细节)。
未经许可,请勿提交受版权保护的作品!
取消
编辑帮助
(在新窗口中打开)