Skip to content

Commit

Permalink
Merge remote-tracking branch 'mainline/develop' into develop-prs
Browse files Browse the repository at this point in the history
  • Loading branch information
vrann committed Sep 29, 2017
2 parents fde5819 + db05632 commit 0e26f4b
Show file tree
Hide file tree
Showing 56 changed files with 262 additions and 252 deletions.
142 changes: 80 additions & 62 deletions dev/tests/acceptance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,39 @@
----

# Prerequisites
* **IMPORTANT**: Configure your Magento Store for [Automated Testing](http://devdocs.magento.com/guides/v2.0/mtf/mtf_quickstart/mtf_quickstart_magento.html)
* [PHP v7.x](http://php.net/manual/en/install.php)
* [Composer v1.4.x](https://getcomposer.org/download/)
* [Java](https://www.java.com/en/download/)
* [Selenium Server](http://www.seleniumhq.org/download/)
* [Selenium Server](http://www.seleniumhq.org/download/) - [v2.53.x](http://selenium-release.storage.googleapis.com/index.html?path=2.53/)
* [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/downloads)
* [Allure CLI](https://docs.qameta.io/allure/latest/#_installing_a_commandline)
* [GitHub](https://desktop.github.com/)
* GitHub Repos:
* [CE Tests](https://github.com/magento-pangolin/magento2ce-acceptance-tests)
* [EE Tests](https://github.com/magento-pangolin/magento2ee-acceptance-tests)
* Configure Magento for [Automated Testing](http://devdocs.magento.com/guides/v2.0/mtf/mtf_quickstart/mtf_quickstart_magento.html)

### Recommendations
* We recommend using [PHPStorm 2017](https://www.jetbrains.com/phpstorm/) for your IDE. They recently added support for [Codeception Test execution](https://blog.jetbrains.com/phpstorm/2017/03/codeception-support-comes-to-phpstorm-2017-1/) which is helpful when debugging.
* We also recommend updating your [$PATH to include](https://stackoverflow.com/questions/7703041/editing-path-variable-on-mac) `vendor/bin` so you can easily execute the necessary `robo` and `codecept` commands instead of `vendor/bin/robo` or `vendor/bin/codecept`.
* We also recommend updating your [$PATH to include](https://stackoverflow.com/questions/7703041/editing-path-variable-on-mac) `./vendor/bin` so you can easily execute the necessary `robo` and `codecept` commands instead of `./vendor/bin/robo` or `./vendor/bin/codecept`.

----

# TEMPORARY INSTALLATION INSTRUCTIONS
Due to the current setup of the Framework you will need to do the following:

* `mkdir [DIRECTORY_NAME]`
* `cd [DIRECTORY_NAME]`
* Pull down - [EE](https://github.com/magento-pangolin/magento2ee)
* Pull down - [CE](https://github.com/magento-pangolin/magento2ce)
* `cd magento2ee`
* `php -f dev/tools/build-ee.php -- --command=link --exclude=true`
* Generate a `github-oauth` token: [Instructions](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/#creating-a-token)
* `touch magento2ce/dev/tests/acceptance/auth.json`
* `nano magento2ce/dev/tests/acceptance/auth.json`
* Replace `<personal access token>` with the token you generated in GitHub.
* Save your work.
* `cd ../magento2ce`
* `cd dev/tests/acceptance`
* `composer install`
* **PLEASE IGNORE THE "Installation" SECTION THAT FOLLOWS, START WITH THE "Building The Framework" SECTION INSTEAD.**

----

Expand All @@ -31,7 +49,7 @@ You can **either** install through composer **or** clone from git repository.
## Git
```
git clone GITHUB_REPO_URL
cd magento2ce-acceptance-tests
cd magento2ce
composer install
```

Expand All @@ -50,93 +68,93 @@ Robo is a task runner for PHP that allows you to alias long complex CLI commands
### Example

* Original: `allure generate tests/_output/allure-results/ -o tests/_output/allure-report/`
* Robo: `robo allure1:generate`
* Robo: `./vendor/bin/robo allure1:generate`

## Available Robo Commands
You can see a list of all available Robo commands by calling `robo` directly in the Terminal.
You can see a list of all available Robo commands by calling `./vendor/bin/robo` in the Terminal.

##### Codeception Robo Commands
* `robo`
* `./vendor/bin/robo`
* Lists all available Robo commands.
* `robo clone:files`
* `./vendor/bin/robo clone:files`
* Duplicate the Example configuration files used to customize the Project
* `robo build:project`
* `./vendor/bin/robo build:project`
* Build the Codeception project
* `robo generate:pages`
* `./vendor/bin/robo generate:pages`
* Generate all Page Objects
* `robo generate:tests`
* `./vendor/bin/robo generate:tests`
* Generate all Tests in PHP
* `robo example`
* `./vendor/bin/robo example`
* Run all Tests marked with the @group tag 'example', using the Chrome environment
* `robo chrome`
* Run all Acceptance tests using the Chrome environment
* `robo firefox`
* Run all Acceptance tests using the FireFox environment
* `robo phantomjs`
* Run all Acceptance tests using the PhantomJS environment
* `robo folder ______`
* Run all Acceptance tests located under the Directory Path provided using the Chrome environment
* `robo group ______`
* `./vendor/bin/robo chrome`
* Run all Functional tests using the Chrome environment
* `./vendor/bin/robo firefox`
* Run all Functional tests using the FireFox environment
* `./vendor/bin/robo phantomjs`
* Run all Functional tests using the PhantomJS environment
* `./vendor/bin/robo folder ______`
* Run all Functional tests located under the Directory Path provided using the Chrome environment
* `./vendor/bin/robo group ______`
* Run all Tests with the specified @group tag, excluding @group 'skip', using the Chrome environment

##### Allure Robo Commands
To determine which version of the Allure command you need to use please run `allure --version`.

* `robo allure1:generate`
* `./vendor/bin/robo allure1:generate`
* Allure v1.x.x - Generate the HTML for the Allure report based on the Test XML output
* `robo allure1:open`
* `./vendor/bin/robo allure1:open`
* Allure v1.x.x - Open the HTML Allure report
* `robo allure1:report`
* `./vendor/bin/robo allure1:report`
* Allure v1.x.x - Generate and open the HTML Allure report
* `robo allure2:generate`
* `./vendor/bin/robo allure2:generate`
* Allure v2.x.x - Generate the HTML for the Allure report based on the Test XML output
* `robo allure2:open`
* `./vendor/bin/robo allure2:open`
* Allure v2.x.x - Open the HTML Allure report
* `robo allure2:report`
* `./vendor/bin/robo allure2:report`
* Allure v2.x.x - Generate and open the HTML Allure report

----

# Building The Framework
After installing the dependencies you will want to build the Codeception project in the [Acceptance Test Framework](https://github.com/magento-pangolin/magento2-acceptance-test-framework), which is a dependency of the CE or EE Tests repo. Run `robo build:project` to complete this task.
After installing the dependencies you will want to build the Codeception project in the [Magento 2 Functional Testing Framework](https://github.com/magento-pangolin/magento2-functional-testing-framework), which is a dependency of the CE or EE Tests repo. Run `./vendor/bin/robo build:project` to complete this task.

`robo build:project`
`./vendor/bin/robo build:project`

----

# Configure the Framework
Before you can generate or run the Tests you will need to clone the Example Configuration files and edit them for your specific Store settings. You can edit these files with out the fear of accidentally committing your credentials or other sensitive information as these files are listed in the *.gitignore* file.
Run the following command to generate these files:
Before you can generate or run the Tests you will need to edit the Configuration files and configure them for your specific Store settings. You can edit these files with out the fear of accidentally committing your credentials or other sensitive information as these files are listed in the *.gitignore* file.

`robo setup`
In the `.env` file you will find key pieces of information that are unique to your local Magento setup that will need to be edited before you can generate tests:
* **MAGENTO_BASE_URL**
* **MAGENTO_BACKEND_NAME**
* **MAGENTO_ADMIN_USERNAME**
* **MAGENTO_ADMIN_PASSWORD**

In these files you will find key pieces of information that are unique to your local Magento setup that will need to be edited (ex **MAGENTO_BASE_URL**, **MAGENTO_BACKEND_NAME**, **MAGENTO_ADMIN_USERNAME**, **MAGENTO_ADMIN_PASSWORD**, etc...).
* **tests/acceptance.suite.yml**
##### Additional Codeception settings can be found in the following files:
* **tests/functional.suite.yml**
* **codeception.dist.yml**
* **.env**

----

# Generate PHP files for Tests
All Tests in the Framework are written in XML and need to have the PHP generated for Codeception to run. Run the following command to generate the PHP files into the following directory: `tests/acceptance/Magento/AcceptanceTest/_generated`
All Tests in the Framework are written in XML and need to have the PHP generated for Codeception to run. Run the following command to generate the PHP files in the following directory (If this directory does not exist it will be created): `dev/tests/acceptance/tests/functional/Magento/FunctionalTest/_generated`

If this directory doesn't exist it will be created.

`robo generate:tests`
`./vendor/bin/robo generate:tests`

----

# Running Tests
## Start the Selenium Server
PLEASE NOTE: You will need to have an instance of the Selenium Server running on your machine before you can execute the Tests.
**PLEASE NOTE**: You will need to have an instance of the Selenium Server running on your machine before you can execute the Tests.

```
cd [LOCATION_OF_SELENIUM_JAR]
java -jar selenium-server-standalone-X.X.X.jar
```

## Run Tests Manually
You can run the Codeception tests directly without using Robo if you'd like. To do so please run `codecept run acceptance` to execute all Acceptance tests that DO NOT include @env tags. IF a Test includes an [@env tag](http://codeception.com/docs/07-AdvancedUsage#Environments) you MUST include the `--env ENV_NAME` flag.
You can run the Codeception tests directly without using Robo if you'd like. To do so please run `./vendor/bin/codecept run functional` to execute all Functional tests that DO NOT include @env tags. IF a Test includes an [@env tag](http://codeception.com/docs/07-AdvancedUsage#Environments) you MUST include the `--env ENV_NAME` flag.

#### Common Codeception Flags:

Expand All @@ -150,17 +168,17 @@ You can run the Codeception tests directly without using Robo if you'd like. To

#### Examples

* Run ALL Acceptance Tests without an @env tag: `codecept run acceptance`
* Run ALL Acceptance Tests without the "skip" @group: `codecept run acceptance --skip-group skip`
* Run ALL Acceptance Tests with the @group tag "example" without the "skip" @group tests: `codecept run acceptance --group example --skip-group skip`
* Run ALL Functional Tests without an @env tag: `./vendor/bin/codecept run functional`
* Run ALL Functional Tests without the "skip" @group: `./vendor/bin/codecept run functional --skip-group skip`
* Run ALL Functional Tests with the @group tag "example" without the "skip" @group tests: `./vendor/bin/codecept run functional --group example --skip-group skip`

## Run Tests using Robo
* Run all Acceptance Tests using the @env tag "chrome": `robo chrome`
* Run all Acceptance Tests using the @env tag "firefox": `robo firefox`
* Run all Acceptance Tests using the @env tag "phantomjs": `robo phantomjs`
* Run all Acceptance Tests using the @group tag "example": `robo example`
* Run all Acceptance Tests using the provided @group tag: `robo group GROUP_NAME`
* Run all Acceptance Tests listed under the provided Folder Path: `robo folder tests/acceptance/Magento/AcceptanceTest/MODULE_NAME`
* Run all Functional Tests using the @env tag "chrome": `./vendor/bin/robo chrome`
* Run all Functional Tests using the @env tag "firefox": `./vendor/bin/robo firefox`
* Run all Functional Tests using the @env tag "phantomjs": `./vendor/bin/robo phantomjs`
* Run all Functional Tests using the @group tag "example": `./vendor/bin/robo example`
* Run all Functional Tests using the provided @group tag: `./vendor/bin/robo group GROUP_NAME`
* Run all Functional Tests listed under the provided Folder Path: `./vendor/bin/robo folder dev/tests/acceptance/tests/functional/Magento/FunctionalTest/MODULE_NAME`

----

Expand All @@ -180,14 +198,14 @@ You can run the following commands in the Terminal to generate and open an Allur
You can run the following Robo commands in the Terminal to generate and open an Allure report (Run the following terminal command for the Allure version: `allure --version`):

##### Allure v1.x.x
* Build the Report: `robo allure1:generate`
* Open the Report: `robo allure1:open`
* Build/Open the Report: `robo allure1:report`
* Build the Report: `./vendor/bin/robo allure1:generate`
* Open the Report: `./vendor/bin/robo allure1:open`
* Build/Open the Report: `./vendor/bin/robo allure1:report`

##### Allure v2.x.x
* Build the Report: `robo allure2:generate`
* Open the Report: `robo allure2:open`
* Build/Open the Report: `robo allure2:report`
* Build the Report: `./vendor/bin/robo allure2:generate`
* Open the Report: `./vendor/bin/robo allure2:open`
* Build/Open the Report: `./vendor/bin/robo allure2:report`

----

Expand All @@ -199,9 +217,9 @@ Due to the interdependent nature of the 2 repos it is recommended to Symlink the
# Troubleshooting
* TimeZone Error - http://stackoverflow.com/questions/18768276/codeception-datetime-error
* TimeZone List - http://php.net/manual/en/timezones.america.php
* System PATH - Make sure you have `vendor/bin/` and `vendor/` listed in your system path so you can run the `codecept` and `robo` commands directly:
* System PATH - Make sure you have `./vendor/bin/`, `vendor/bin/` and `vendor/` listed in your system path so you can run the `codecept` and `robo` commands directly:

`sudo nano /etc/private/paths`
`sudo nano /etc/paths`

* StackOverflow Help: https://stackoverflow.com/questions/7703041/editing-path-variable-on-mac
* Allure `@env error` - Allure recently changed their Codeception Adapter that breaks Codeception when tests include the `@env` tag. A workaround for this error is to revert the changes they made to a function.
Expand All @@ -225,4 +243,4 @@ public function _initialize(array $ignoredAnnotations = [])
Model\Provider::setOutputDirectory($outputDirectory);
}
}
```
```
24 changes: 8 additions & 16 deletions dev/tests/acceptance/RoboFile.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ class RoboFile extends \Robo\Tasks
{
use Robo\Task\Base\loadShortcuts;

/**
* Complete all Project Setup tasks
*/
function setup()
{
$this->_exec('vendor/bin/robo clone:files');
$this->_exec('vendor/bin/codecept build');
}

/**
* Duplicate the Example configuration files used to customize the Project for customization
*/
Expand All @@ -33,12 +24,13 @@ function cloneFiles()
}

/**
* Clone the Example configuration files
* Build the Codeception project
*/
function buildProject()
{
$this->cloneFiles();
$this->_exec('vendor/bin/codecept build');
$this->_exec('./vendor/bin/codecept build');
}

/**
Expand All @@ -56,47 +48,47 @@ function generateTests()
*/
function chrome()
{
$this->_exec('codecept run functional --env chrome --skip-group skip');
$this->_exec('./vendor/bin/codecept run functional --env chrome --skip-group skip');
}

/**
* Run all Acceptance tests using the FireFox environment
*/
function firefox()
{
$this->_exec('codecept run functional --env firefox --skip-group skip');
$this->_exec('./vendor/bin/codecept run functional --env firefox --skip-group skip');
}

/**
* Run all Acceptance tests using the PhantomJS environment
*/
function phantomjs()
{
$this->_exec('codecept run functional --env phantomjs --skip-group skip');
$this->_exec('./vendor/bin/codecept run functional --env phantomjs --skip-group skip');
}

/**
* Run all Tests with the specified @group tag, excluding @group 'skip', using the Chrome environment
*/
function group($args = '')
{
$this->taskExec('codecept run functional --verbose --steps --env chrome --skip-group skip --group')->args($args)->run();
$this->taskExec('./vendor/bin/codecept run functional --verbose --steps --env chrome --skip-group skip --group')->args($args)->run();
}

/**
* Run all Acceptance tests located under the Directory Path provided using the Chrome environment
*/
function folder($args = '')
{
$this->taskExec('codecept run functional --env chrome')->args($args)->run();
$this->taskExec('./vendor/bin/codecept run functional --env chrome')->args($args)->run();
}

/**
* Run all Tests marked with the @group tag 'example', using the Chrome environment
*/
function example()
{
$this->_exec('codecept run --env chrome --group example --skip-group skip');
$this->_exec('./vendor/bin/codecept run --env chrome --group example --skip-group skip');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="AdminLoginFormSection">
<element name="username" type="input" locator="#username"/>
<element name="password" type="input" locator="#login"/>
<element name="signIn" type="button" locator=".actions .action-primary" timeout="30"/>
<element name="username" type="input" selector="#username"/>
<element name="password" type="input" selector="#login"/>
<element name="signIn" type="button" selector=".actions .action-primary" timeout="30"/>
</section>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
-->

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
xsi:noNamespaceSchemaLocation="../../../../../../../../../../magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="AdminMessagesSection">
<element name="test" type="input" locator=".test"/>
<element name="test" type="input" selector=".test"/>
</section>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<data key="sku" unique="suffix">SimpleProduct</data>
<data key="type_id">simple</data>
<data key="attribute_set_id">4</data>
<data key="name">SimpleProduct</data>
<data key="name" unique="suffix">SimpleProduct</data>
<data key="price">123.00</data>
<data key="visibility">4</data>
<data key="status">1</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="AdminCategoryBasicFieldSection">
<element name="IncludeInMenu" type="checkbox" locator="input[name='include_in_menu']"/>
<element name="EnableCategory" type="checkbox" locator="input[name='is_active']"/>
<element name="CategoryNameInput" type="input" locator="input[name='name']"/>
<element name="IncludeInMenu" type="checkbox" selector="input[name='include_in_menu']"/>
<element name="EnableCategory" type="checkbox" selector="input[name='is_active']"/>
<element name="CategoryNameInput" type="input" selector="input[name='name']"/>
</section>
</config>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
<section name="AdminCategoryMainActionsSection">
<element name="SaveButton" type="button" locator=".page-actions-inner #save" timeout="30"/>
<element name="SaveButton" type="button" selector=".page-actions-inner #save" timeout="30"/>
</section>
</config>
Loading

0 comments on commit 0e26f4b

Please sign in to comment.