mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-02 13:02:24 +08:00
Merge pull request #4671 from TriAnMan/test-runner
Provide aggregate test runner
This commit is contained in:
@ -113,7 +113,7 @@ it will upgrade your database to the last state according migrations.
|
||||
|
||||
To be able to run acceptance tests you need a running webserver. For this you can use the php builtin server and run it in the directory where your main project folder is located. For example if your application is located in `/www/advanced` all you need to is:
|
||||
`cd /www` and then `php -S 127.0.0.1:8080` because the default configuration of acceptance tests expects the url of the application to be `/advanced/`.
|
||||
If you already have a server configured or your application is not located in a folder called `advanced`, you may need to adjust the `TEST_ENTRY_URL` in `frontend/tests/_bootstrap.php` and `backend/tests/_bootstrap.php`.
|
||||
If you already have a server configured or your application is not located in a folder called `advanced`, you may need to adjust the `test_entry_url` in `backend/codeception.yml` and `frontend/codeception.yml`.
|
||||
|
||||
After that is done you should be able to run your tests, for example to run `frontend` tests do:
|
||||
|
||||
@ -123,5 +123,7 @@ After that is done you should be able to run your tests, for example to run `fro
|
||||
|
||||
In similar way you can run tests for other application tiers - `backend`, `console`, `common`.
|
||||
|
||||
If you already have run `../vendor/bin/codecept build` for each application, you can run all tests by one command: `vendor/bin/codecept run`
|
||||
|
||||
You also can adjust you application suite configs and `_bootstrap.php` settings to use other urls and files, as it is can be done in `yii2-basic`.
|
||||
Current template also includes [yii2-faker](https://github.com/yiisoft/yii2/tree/master/extensions/faker) extension, that is correctly setup for each application tier.
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
namespace: backend
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
@ -17,3 +18,7 @@ modules:
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
config:
|
||||
# the entry script URL (without host info) for functional and acceptance tests
|
||||
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
|
||||
test_entry_url: /advanced/backend/web/index-test.php
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
<?php
|
||||
|
||||
// the entry script URL (without host info) for functional and acceptance tests
|
||||
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
|
||||
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/advanced/backend/web/index-test.php');
|
||||
|
||||
// the entry script file path for functional and acceptance tests
|
||||
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php');
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
@ -18,6 +11,8 @@ require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
|
||||
require(__DIR__ . '/../../common/config/aliases.php');
|
||||
|
||||
// set correct script paths
|
||||
$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||
|
||||
// the entry script file path for functional and acceptance tests
|
||||
$_SERVER['SCRIPT_FILENAME'] = dirname(__DIR__) . '/web/index-test.php';
|
||||
$_SERVER['SCRIPT_NAME'] = \Codeception\Configuration::config()['config']['test_entry_url'];
|
||||
$_SERVER['SERVER_NAME'] = 'localhost';
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use common\tests\_pages\LoginPage;
|
||||
use backend\WebGuy;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure login page works');
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use common\tests\_pages\LoginPage;
|
||||
use backend\TestGuy;
|
||||
|
||||
$I = new TestGuy($scenario);
|
||||
$I->wantTo('ensure login page works');
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// set correct script paths
|
||||
$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||
$_SERVER['SCRIPT_FILENAME'] = dirname(dirname(__DIR__)) . '/web/index-test.php';
|
||||
$_SERVER['SCRIPT_NAME'] = \Codeception\Configuration::config()['config']['test_entry_url'];;
|
||||
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
require(__DIR__ . '/../../config/main.php'),
|
||||
|
||||
11
apps/advanced/codeception.yml
Normal file
11
apps/advanced/codeception.yml
Normal file
@ -0,0 +1,11 @@
|
||||
include:
|
||||
- common
|
||||
- console
|
||||
- backend
|
||||
- frontend
|
||||
|
||||
paths:
|
||||
log: tests/_log
|
||||
|
||||
settings:
|
||||
colors: true
|
||||
@ -1,3 +1,4 @@
|
||||
namespace: common
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
<?php
|
||||
|
||||
// the entry script URL (without host info) for functional and acceptance tests
|
||||
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
|
||||
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php');
|
||||
|
||||
// the entry script file path for functional and acceptance tests
|
||||
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/index-test.php');
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
@ -18,6 +11,4 @@ require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
|
||||
require(__DIR__ . '/../../common/config/aliases.php');
|
||||
|
||||
// set correct script paths
|
||||
$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||
$_SERVER['SERVER_NAME'] = 'localhost';
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
namespace: console
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
<?php
|
||||
|
||||
// the entry script URL (without host info) for functional and acceptance tests
|
||||
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
|
||||
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/index-test.php');
|
||||
|
||||
// the entry script file path for functional and acceptance tests
|
||||
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/index-test.php');
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
@ -18,6 +11,4 @@ require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
|
||||
require(__DIR__ . '/../../common/config/aliases.php');
|
||||
|
||||
// set correct script paths
|
||||
$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||
$_SERVER['SERVER_NAME'] = 'localhost';
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
namespace: frontend
|
||||
actor: Tester
|
||||
paths:
|
||||
tests: tests
|
||||
@ -17,3 +18,7 @@ modules:
|
||||
user: ''
|
||||
password: ''
|
||||
dump: tests/_data/dump.sql
|
||||
config:
|
||||
# the entry script URL (without host info) for functional and acceptance tests
|
||||
# PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
|
||||
test_entry_url: /advanced/frontend/web/index-test.php
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
<?php
|
||||
|
||||
// the entry script URL (without host info) for functional and acceptance tests
|
||||
// PLEASE ADJUST IT TO THE ACTUAL ENTRY SCRIPT URL
|
||||
defined('TEST_ENTRY_URL') or define('TEST_ENTRY_URL', '/advanced/frontend/web/index-test.php');
|
||||
|
||||
// the entry script file path for functional and acceptance tests
|
||||
defined('TEST_ENTRY_FILE') or define('TEST_ENTRY_FILE', dirname(__DIR__) . '/web/index-test.php');
|
||||
|
||||
defined('YII_DEBUG') or define('YII_DEBUG', true);
|
||||
|
||||
defined('YII_ENV') or define('YII_ENV', 'test');
|
||||
@ -18,6 +11,8 @@ require_once(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php');
|
||||
require(__DIR__ . '/../../common/config/aliases.php');
|
||||
|
||||
// set correct script paths
|
||||
$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||
|
||||
// the entry script file path for functional and acceptance tests
|
||||
$_SERVER['SCRIPT_FILENAME'] = dirname(__DIR__) . '/web/index-test.php';
|
||||
$_SERVER['SCRIPT_NAME'] = \Codeception\Configuration::config()['config']['test_entry_url'];
|
||||
$_SERVER['SERVER_NAME'] = 'localhost';
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use frontend\tests\_pages\AboutPage;
|
||||
use frontend\WebGuy;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that about works');
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use frontend\tests\_pages\ContactPage;
|
||||
use frontend\WebGuy;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that contact works');
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use frontend\WebGuy;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure that home page works');
|
||||
$I->amOnPage(Yii::$app->homeUrl);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use common\tests\_pages\LoginPage;
|
||||
use frontend\WebGuy;
|
||||
|
||||
$I = new WebGuy($scenario);
|
||||
$I->wantTo('ensure login page works');
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use frontend\tests\_pages\AboutPage;
|
||||
use frontend\TestGuy;
|
||||
|
||||
$I = new TestGuy($scenario);
|
||||
$I->wantTo('ensure that about works');
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use frontend\tests\_pages\ContactPage;
|
||||
use frontend\TestGuy;
|
||||
|
||||
$I = new TestGuy($scenario);
|
||||
$I->wantTo('ensure that contact works');
|
||||
|
||||
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use frontend\TestGuy;
|
||||
|
||||
$I = new TestGuy($scenario);
|
||||
$I->wantTo('ensure that home page works');
|
||||
$I->amOnPage(Yii::$app->homeUrl);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use common\tests\_pages\LoginPage;
|
||||
use frontend\TestGuy;
|
||||
|
||||
$I = new TestGuy($scenario);
|
||||
$I->wantTo('ensure login page works');
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
|
||||
// set correct script paths
|
||||
$_SERVER['SCRIPT_FILENAME'] = TEST_ENTRY_FILE;
|
||||
$_SERVER['SCRIPT_NAME'] = TEST_ENTRY_URL;
|
||||
$_SERVER['SCRIPT_FILENAME'] = dirname(dirname(__DIR__)) . '/web/index-test.php';
|
||||
$_SERVER['SCRIPT_NAME'] = \Codeception\Configuration::config()['config']['test_entry_url'];;
|
||||
|
||||
return yii\helpers\ArrayHelper::merge(
|
||||
require(__DIR__ . '/../../config/main.php'),
|
||||
|
||||
2
apps/advanced/tests/_log/.gitignore
vendored
Normal file
2
apps/advanced/tests/_log/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
Reference in New Issue
Block a user