Skip to content

Commit

Permalink
[TASK] Refactor acceptance tests
Browse files Browse the repository at this point in the history
typo3/testing-framework got a major release:
composer update typo3/testing-framework ^4.0

* codeception acceptance tests now live in a proper php namespace
* merged installation suites yml files into one
* installer tests are now one suite with different environment settings
* aligned with changes in typo3/testing-framework
* renamed Acceptance test suite to Backend test suite
* removed Admin/Editor steps, replaced with useExistingLogin('role')

Resolves: #85472
Releases: master
Change-Id: Ia049b43f5f9f645dddb509bde557ad83a7ac9023
Reviewed-on: https://review.typo3.org/57461
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
DavertMik authored and lolli42 committed Jul 7, 2018
1 parent 49f4e9a commit aab3910
Show file tree
Hide file tree
Showing 55 changed files with 1,499 additions and 1,210 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -60,3 +60,5 @@ phantomjsdriver.log
#
# root .htaccess file
/.htaccess

typo3/sysext/core/Tests/Acceptance/Support/_generated/
2 changes: 2 additions & 0 deletions Build/Scripts/annotationChecker.php
Expand Up @@ -58,6 +58,8 @@ public function enterNode(Node $node)
'api', 'author', 'category', 'copyright', 'deprecated', 'example', 'filesource', 'global', 'ignore', 'internal', 'license', 'link', 'method', 'package', 'param', 'property', 'property-read', 'property-write', 'return', 'see', 'since', 'source', 'subpackage', 'throws', 'todo', 'TODO', 'usedby', 'uses', 'var', 'version',
// PHPUnit tags
'codeCoverageIgnore', 'codeCoverageIgnoreStart', 'codeCoverageIgnoreEnd', 'test', 'covers', 'dataProvider', 'group', 'skip', 'depends', 'expectedException', 'before',
// codeception tags
'env',
// PHPCheckStyle
'SuppressWarnings', 'noinspection',
// Extbase related (deprecated)
Expand Down
46 changes: 27 additions & 19 deletions Build/bamboo/src/main/java/core/AbstractCoreSpec.java
Expand Up @@ -56,22 +56,31 @@ abstract public class AbstractCoreSpec {
" typo3DatabaseHost=\"localhost\"" +
" typo3InstallToolPassword=\"klaus\"";

protected String installCredentialsMysql =
"typo3InstallMysqlDatabaseName=\"func_install\"" +
" typo3InstallMysqlDatabaseUsername=\"funcu\"" +
" typo3InstallMysqlDatabasePassword=\"funcp\"" +
" typo3InstallMysqlDatabaseHost=\"localhost\"";

protected String credentialsMssql =
"typo3DatabaseDriver=\"sqlsrv\"" +
" typo3DatabaseName=\"func\"" +
" typo3DatabasePassword='Test1234!'" +
" typo3DatabaseUsername=\"SA\"" +
" typo3DatabaseHost=\"localhost\"" +
" typo3DatabasePort=\"1433\"" +
" typo3DatabaseCharset=\"utf-8\"" +
" typo3InstallToolPassword=\"klaus\"";
" typo3DatabaseCharset=\"utf-8\"";

protected String credentialsPgsql =
"typo3DatabaseDriver=\"pdo_pgsql\"" +
" typo3DatabaseName=\"func\"" +
" typo3DatabaseUsername=\"bamboo\"" +
" typo3DatabaseHost=\"localhost\"" +
" typo3InstallToolPassword=\"klaus\"";
" typo3DatabaseHost=\"localhost\"";

protected String installCredentialsPgsql =
"typo3InstallPostgresqlDatabaseName=\"func_atipgsql\"" +
" typo3InstallPostgresqlDatabaseUsername=\"bamboo\"" +
" typo3InstallPostgresqlDatabaseHost=\"localhost\"";

protected String credentialsSqlite =
"typo3DatabaseDriver=\"pdo_sqlite\"";
Expand Down Expand Up @@ -181,14 +190,14 @@ protected Job getJobAcceptanceTestInstallMysql(Requirement requirement, String r
this.getTaskComposerInstall(),
this.getTaskPrepareAcceptanceTest(),
new CommandTask()
.description("Execute codeception AcceptanceInstallMysql suite")
.description("Install TYPO3 on mysql")
.executable("codecept")
.argument("run AcceptanceInstallMysql -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallMysql.yml --xml reports.xml --html reports.html")
.environmentVariables(this.credentialsMysql)
.argument("run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=mysql,headless --xml reports.xml --html reports.html")
.environmentVariables(this.installCredentialsMysql)
)
.finalTasks(
new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
.resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallMysql/reports.xml"),
.resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml"),
this.getTaskDeleteMysqlDatabases(),
this.getTaskTearDownAcceptanceTestSetup()
)
Expand All @@ -197,7 +206,7 @@ protected Job getJobAcceptanceTestInstallMysql(Requirement requirement, String r
)
.artifacts(new Artifact()
.name("Test Report")
.copyPattern("typo3temp/var/tests/AcceptanceReportsInstallMysql/")
.copyPattern("typo3temp/var/tests/AcceptanceReports/")
.shared(false)
)
.cleanWorkingDirectory(true);
Expand All @@ -219,14 +228,14 @@ protected Job getJobAcceptanceTestInstallPgsql(Requirement requirement, String r
this.getTaskComposerInstall(),
this.getTaskPrepareAcceptanceTest(),
new CommandTask()
.description("Execute codeception AcceptanceInstallPgsql suite")
.description("Install TYPO3 on postgresql")
.executable("codecept")
.argument("run AcceptanceInstallPgsql -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallPgsql.yml --xml reports.xml --html reports.html")
.environmentVariables(this.credentialsPgsql)
.argument("run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=postgresql,headless --xml reports.xml --html reports.html")
.environmentVariables(this.installCredentialsPgsql)
)
.finalTasks(
new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
.resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallPgsql/reports.xml"),
.resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml"),
this.getTaskDeletePgsqlDatabases(),
this.getTaskTearDownAcceptanceTestSetup()
)
Expand All @@ -235,7 +244,7 @@ protected Job getJobAcceptanceTestInstallPgsql(Requirement requirement, String r
)
.artifacts(new Artifact()
.name("Test Report")
.copyPattern("typo3temp/var/tests/AcceptanceReportsInstallPgsql/")
.copyPattern("typo3temp/var/tests/AcceptanceReports/")
.shared(false)
)
.cleanWorkingDirectory(true);
Expand All @@ -257,22 +266,21 @@ protected Job getJobAcceptanceTestInstallSqlite(Requirement requirement, String
this.getTaskComposerInstall(),
this.getTaskPrepareAcceptanceTest(),
new CommandTask()
.description("Execute codeception AcceptanceInstallSqlite suite")
.description("Install TYPO3 on sqlite")
.executable("codecept")
.argument("run AcceptanceInstallSqlite -d -c " + this.testingFrameworkBuildPath + "AcceptanceTestsInstallSqlite.yml --xml reports.xml --html reports.html")
.environmentVariables(this.credentialsSqlite)
.argument("run Install -d -c typo3/sysext/core/Tests/codeception.yml --env=sqlite,headless --xml reports.xml --html reports.html")
)
.finalTasks(
new TestParserTask(TestParserTaskProperties.TestType.JUNIT)
.resultDirectories("typo3temp/var/tests/AcceptanceReportsInstallSqlite/reports.xml"),
.resultDirectories("typo3temp/var/tests/AcceptanceReports/reports.xml"),
this.getTaskTearDownAcceptanceTestSetup()
)
.requirements(
requirement
)
.artifacts(new Artifact()
.name("Test Report")
.copyPattern("typo3temp/var/tests/AcceptanceReportsInstallSqlite/")
.copyPattern("typo3temp/var/tests/AcceptanceReports/")
.shared(false)
)
.cleanWorkingDirectory(true);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -64,7 +64,7 @@
"fiunchinho/phpunit-randomizer": "^4.0",
"friendsofphp/php-cs-fixer": "^2.0",
"typo3/cms-styleguide": "^9.1",
"typo3/testing-framework": "^3.8"
"typo3/testing-framework": "^4.0"
},
"suggest": {
"ext-gd": "GDlib/Freetype is required for building images with text (GIFBUILDER) and can also be used to scale images",
Expand Down
28 changes: 13 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 0 additions & 21 deletions typo3/sysext/core/Tests/Acceptance.suite.yml

This file was deleted.

38 changes: 38 additions & 0 deletions typo3/sysext/core/Tests/Acceptance/Backend.suite.yml
@@ -0,0 +1,38 @@
class_name: BackendTester
modules:
enabled:
- WebDriver:
url: http://master:8000/typo3temp/var/tests/acceptance
browser: chrome
wait: 1
host: chrome
- \TYPO3\TestingFramework\Core\Acceptance\Helper\Acceptance
- \TYPO3\TestingFramework\Core\Acceptance\Helper\Login:
sessions:
# This sessions must exist in the database fixture to get a logged in state.
editor: ff83dfd81e20b34c27d3e97771a4525a
admin: 886526ce72b86870739cc41991144ec1
- Asserts

extensions:
enabled:
- TYPO3\TestingFramework\Core\Acceptance\Extension\BackendCoreEnvironment

env:
headless:
modules:
config:
WebDriver:
host: localhost
port: 9515
url: http://localhost:8000/typo3temp/var/tests/acceptance
capabilities:
# Disable the "scroll to element before clicking" behavior as this breaks tests
# where for example a fixed docbar is used. Selenium scrolls to the element before
# clicking it and then complains that it can't click the element because another elemnt
# is overlaying it.
# You have to ensure that the element is in the viewport by your own before clicking it!
# You can simply do that by scrolling to it.
elementScrollBehavior: 1
chromeOptions:
args: ["--headless", "--no-sandbox", "window-size=1280x1024", "--proxy-server='direct://'", "--proxy-bypass-list=*", "--disable-gpu"]
@@ -1,6 +1,5 @@
<?php
declare(strict_types = 1);

namespace TYPO3\CMS\Core\Tests\Acceptance\Backend\BackendUser;

/*
Expand All @@ -16,36 +15,36 @@
* The TYPO3 project - inspiring people to share!
*/

use TYPO3\TestingFramework\Core\Acceptance\Step\Backend\Admin;
use TYPO3\CMS\Core\Tests\Acceptance\Support\BackendTester;

/**
* Tests concerning the compare view of BE user module
*/
class CompareUserCest
{
/**
* @param Admin $I
* @param BackendTester $I
*/
public function _before(Admin $I)
public function _before(BackendTester $I)
{
$I->useExistingSession();
$I->useExistingSession('admin');

$I->see('Backend users');
$I->click('Backend users');
$I->switchToContentFrame();
}

/**
* @param Admin $I
* @param BackendTester $I
*/
public function editingBeUserRecordsFromCompareViewWorks(Admin $I)
public function editingBeUserRecordsFromCompareViewWorks(BackendTester $I)
{
// put two users into compare list
$I->see('Backend User Listing');
$I->click('#typo3-backend-user-list > tbody > tr:nth-child(1) > td.col-control > div:nth-child(3) > a');
$I->waitForElementVisible('table#typo3-backend-user-list');
$I->click('#typo3-backend-user-list > tbody > tr:nth-child(2) > td.col-control > div:nth-child(3) > a');
$I->waitForElementVisible('table#typo3-backend-user-list-compare');
$I->waitForElementVisible('table#typo3-backend-user-list-compare', 20);
$I->canSeeNumberOfElements('#typo3-backend-user-list-compare tbody tr', 2);
$I->click('body > div > div.module-body.t3js-module-body > form:nth-child(4) > input');
$I->waitForElementVisible('table.table-striped');
Expand All @@ -58,7 +57,7 @@ public function editingBeUserRecordsFromCompareViewWorks(Admin $I)
$I->canSee('Edit Backend user "' . $usernameFirstCompare . '" on root level');

// back to compare view
$I->click('div.module-docheader .btn.t3js-editform-close');
$I->click('.module-docheader .btn.t3js-editform-close');
$I->waitForElementVisible('table.table-striped');
$I->canSee('Compare backend users', 'h1');

Expand Down

0 comments on commit aab3910

Please sign in to comment.