我正在为Joomla构建一个CodeCeption验收测试环境。为了更容易地在任何开发人员的机器上再现测试,我想提供一个基于Docker的环境。
我正在使用docker编写创建环境:
web:
image: php:5-apache
volumes:
- ../..:/var/www/html
ports:
- 8080:80
links:
- db:db
db:
image: mysql
volumes:
- ../../tests/_envs/sql:/var/lib/mysql
ports:
- 3306:3306
hub:
image: selenium/hub
ports:
- 4444:4444
firefox:
image: selenium/node-firefox-debug
ports:
- 5900
links:
- hub:hub
CodeCeption设置如下(JoomlaBrowser只是扩展了WebDriver,添加了特定于Joomla的功能):
class_name: AcceptanceTester
modules:
enabled:
- JoomlaBrowser:
url: 'http://localhost:8080/' # the url that points to the joomla installation at /tests/system/joomla-cms
browser: 'firefox'
window_size: 1024x768
capabilities:
unexpectedAlertBehaviour: 'accept'
username: 'admin'
password: 'admin'
database host: 'localhost' # place where the Application is Hosted #server Address
database user: 'root' # MySQL Server user ID, usually root
database password: '1234' # MySQL Server password, usually empty or root
database name: 'dbname' # DB Name, at the Server
database type: 'mysqli' # type in lowercase one of the options: MySQL\MySQLi\PDO
database prefix: 'jos_' # DB Prefix for tables
install sample data: 'Yes' # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
sample data: 'Default English (GB) Sample Data' # Default Sample Data
admin email: 'admin@mydomain.com' # email Id of the Admin
language: 'English (United Kingdom)' # Language in which you want the Application to be Installed
joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
- \Helper\Acceptance
error_reporting: E_ALL
一旦启动,web环境就可以通过http://localhost:8080 (按预期重定向到Joomla的新副本上的installation/index.php )进行手动访问。http://localhost:4444/grid/console上的Selenium网格也是如此。然而,在运行CodeCeption验收测试时,测试只会看到“问题加载页”浏览器消息。
我错过了什么?
发布于 2016-01-26 09:56:31
终于自己解决了。
问题是,火狐容器不应该访问localhost
,而应该访问web
容器。因此,需要一个到该容器的链接。固定的docker-compose.yml
文件现在看起来像
web:
image: php:5-apache
volumes:
- .:/var/www/html
ports:
- "8080:80"
links:
- db:db
db:
image: mysql
volumes:
- tests/_envs/sql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=root
ports:
- "3306:3306"
hub:
image: selenium/hub
ports:
- "4444:4444"
firefox:
image: selenium/node-firefox-debug
links:
- hub:hub
- web:web
ports:
- "5900:5900"
expose:
- "5555"
主要的区别是链接到web
。
验收测试设置必须相应更改:
class_name: AcceptanceTester
modules:
enabled:
- JoomlaBrowser:
url: 'http://web/' # the url that points to the joomla installation at /tests/system/joomla-cms
browser: 'firefox'
window_size: 1024x768
capabilities:
unexpectedAlertBehaviour: 'accept'
username: 'admin'
password: 'admin'
database host: 'localhost' # place where the Application is Hosted #server Address
database user: 'root' # MySQL Server user ID, usually root
database password: '1234' # MySQL Server password, usually empty or root
database name: 'dbname' # DB Name, at the Server
database type: 'mysqli' # type in lowercase one of the options: MySQL\MySQLi\PDO
database prefix: 'jos_' # DB Prefix for tables
install sample data: 'Yes' # Do you want to Download the Sample Data Along with Joomla Installation, then keep it Yes
sample data: 'Default English (GB) Sample Data' # Default Sample Data
admin email: 'admin@mydomain.com' # email Id of the Admin
language: 'English (United Kingdom)' # Language in which you want the Application to be Installed
joomla folder: '/home/.../path to Joomla Folder' # Path to Joomla installation where we execute the tests
- \Helper\Acceptance
error_reporting: E_ALL
这里的主要更改是将URL指向http:/web/
而不是localhost
。
https://sqa.stackexchange.com/questions/16558
复制