silverstripe-australia/ssautesting
最新稳定版本:4.1.2
Composer 安装命令:
composer require --dev silverstripe-australia/ssautesting
包简介
Some extensions to the default SS test structures to allow parametrisation in CI builds, as well as a framework for selenium testing.
README 文档
README
Adds several helpers to the base SilverStripe testing framework to simplify hooking the testing process into CI servers such as Jenkins, by parameterising several configuration options.
Additionally, the module provides the SymbioteSeleniumTestCase which provides a
simpler API for writing Selenium powered tests.
Command line parameters
To help with test execution, there's a few parameters that can be used to assist in speeding things up if you're repeatedly running tests.
build=0- do not perform a dev/build during test initialisationclean=0- do not wipe out existing database stateflush=0- do not perform a manifest flush during test initialisation
Selenium
To run just the selenium tests, a commandline such as
php vendor/silverstripe/framework/cli-script.php dev/tests/module/test-assist \
flush=1 build=1 selenium_host=127.0.0.1 browser=firefox \
test_url=http://my.silverstripe.site/ test_type=SymbioteSeleniumTestCase SkipTests=symbioteseleniumtestcase \
admin_user=admin admin_pass=admin
Note: The trailing slash in the URL is important!
should get you going. Note that you will need to have selenium server running for this to work. A command such as the following will start selenium server in a virtual framebuffer, meaning the windows don't launch all over your screen!
#!/bin/sh
/usr/bin/xvfb-run -e /var/log/selenium/xvfb-selenium.log -n 10 \
-s "-screen 10 1024x768x8" \
java -jar /home/path/to/programs/selenium-server-standalone-2.39.0.jar \
-port 4444 -log /var/log/selenium/server.log
However it can be useful to run the selenium server directly from the commandline to debug why a test has failed.
Diagnostic tools
Swap from using MySQLDatabase to DevMySQLDatabase in your DB config
--- Name: dev_filters --- Injector: RequestProcessor: properties: filters: - %$QueryDisplayFilter - %$RequestTimerFilter
Codeception
To hook codeception up for your project, you will need to create a codeception.yml config file at the top level of your project.
include:
- mymodule/codeception
paths:
log: path/to/logdir
codeception.yml defines the paths of modules to be included in the test runs.
Within your module, you can then create a namespaced project specific set of tests to be included in that top level path.
- mkdir modulename/codeception
- cd modulename/codeception
- ../../vendor/bin/codecept bootstrap --namespace modulenamespace
- mv codeception.yml codeception.dist.yml
- touch .gitignore
Note that 'modulenamespace' can be anything, as long as it's a valid PHP namespace string
Next, create a new codeception.yml file that contains just your local
environment codeception configuration; this will typically be the local URL
for developer testing, ie
modules:
config:
WebDriver:
url: http://project.clients.sslocal
browser: chrome
Update modulename/codeception/tests/functional.suite.xml and add a couple of
modules
class_name: FunctionalTester
modules:
enabled:
- \modulename\Helper\Functional
- WebDriver # new
- \Symbiote\TestAssist\SilverstripeFunctional # new
Update modulename/codeception/tests/_bootstrap.php to include the
SilverstripFunctional helper
<?php
// This is global bootstrap for autoloading
include_once 'test-assist/code/codeception/SilverstripeFunctional.php';
Update modulename/codeception/tests/unit/_bootstrap.php to set up the
environment for unit testing:
<?php
// Unit testing specific setup
include_once 'vendor/silverstripe/framework/tests/bootstrap.php';
Now, add the following to .gitignore
codeception.yml
/tests/_output/
Include your module in the top level codeception.yml
include:
- modulename/codeception
And lastly, start writing tests! In modulename/codeception/tests/functional/FirstTestCept.php
<?php
use \Codeception\Util\Locator;
$I = new \modulenamespace\FunctionalTester($scenario);
$I->wantTo("Test the homepage");
$I->amOnPage("/");
$I->see("Home");
In modulename/codeception/tests/unit/SmokeTest.php
<?php
class PageTest extends SapphireTest {
public function testMyMethod() {
$this->assertEquals(2, Page::MyMethod());
}
}
From the top level of the project
$ ./vendor/bin/codecept run
A note on better buttons
Some of the in-built helper methods won't work if better buttons is installed. If this the case, add
\Symbiote\TestAssist\SilverstripeFunctional.use_better_buttons: true
in codeception.dist.yml
silverstripe-australia/ssautesting 适用场景与选型建议
silverstripe-australia/ssautesting 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 19.93k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2015 年 03 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「testing」 「selenium」 「silverstripe」 「continuous integration」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe-australia/ssautesting 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe-australia/ssautesting 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe-australia/ssautesting 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Testing Suite For Lumen like Laravel does.
Selenium4 (WebDriver) driver for Mink framework
PHP Library for Selenium
Selenium driver for Mink framework
Analytics chooser extensions for site settings.
统计信息
- 总下载量: 19.93k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-03-17