magetest / behatmage Goto Github PK
View Code? Open in Web Editor NEWBehat for Magento
License: MIT License
Behat for Magento
License: MIT License
Add configuration to override the cache flush before scenarios to improve speed of tests.
Hi,
I am using this setup in combination with the latest selenium rc.
Everytime i pass a condition into my wait like:
I get the following error:
Build info: version: '2.43.1', revision: '5163bce', time: '2014-09-10 16:27:33'
System info: host: 'toonvd-Precision-M4600', ip: '127.0.0.1', os.name: 'Linux', os.arch: 'amd64', os.version: '3.13.0-24-generic', java.version: '1.8.0_20'
Driver info: driver.version: unknown
This was not a problem with the old version of this repo (like 6 months ago).
Do you guys have any ideas on how to fix this?
Thx
Hello,
I noticed that when running my test a second time, the fixtures from the previous run isn't cleaned and I get an "sql-duplicate-key-warning". Going through the code it looks like the AfterScenarioLister isn´t registered anywhere and subsequently never fires after the test suite is run.
Create a GitHub Pages website that will include all the information, documentation and examples.
Create content and website to support the functionality
Hello,
Could you please add fixtures for the following:
Thanks,
Norbert
The simple steps like "I should see" etc. do not work
Running behat as described in the README.md it fails to do this:
Scenario: Display Header
Given I log in as admin user "admin" identified by "123123pass"
When I open admin URI "/admin/process/list"
Then I should see text "Index Management"
In a dry-run it tells me to create the step:
You can implement step definitions for undefined steps with these snippets:
/**
* @Then /^I should see text$/
*/
public function iShouldSeeText()
{
throw new PendingException();
}
Behat 3 has now been released from some time and offers enhanced functionality for suites of features and other optimisations. We have also created a stand along library for handling fixture generation and management. However we also need to retain a version of BehatMage that supports Behat 2 as Behat 3 is not backwards compatible. The current beta branch is feature/Behat3
My objectives are:
Describe the process of contributing and provide details of how to submit a pull request
I've got this email from packagist:
Disclaimer: These email notifications are in experimental stage, if you find
that they look strange or contain false or misleading information please
reply to this email to let us know.
The magetest/magento-behat-extension package of which you are a maintainer has
failed to update due to invalid data contained in your composer.json.
Please address this as soon as possible since the package stopped updating.
It is recommended that you use composer validate
to check for errors when you
change your composer.json.
Below is the full update log which should highlight errors as
"Skipped branch ...":
[Composer\Repository\InvalidRepositoryException]: Some branches contained invalid data and were discarded, it is advised to review the log and fix any issues present in branches
Reading composer.json of magetest/magento-behat-extension (0.0.3)
Importing tag 0.0.3 (0.0.3.0)
Reading composer.json of magetest/magento-behat-extension (0.0.2)
Importing tag 0.0.2 (0.0.2.0)
Skipped tag 0.0.2, Invalid package information:
require-dev.phpspec/phpspec2 : invalid version constraint (Could not parse version constraint magento-demo: Invalid version string "magento-demo")
Reading composer.json of magetest/magento-behat-extension (0.0.1)
Importing tag 0.0.1 (0.0.1.0)
Skipped tag 0.0.1, Invalid package information:
require-dev.phpspec/phpspec2 : invalid version constraint (Could not parse version constraint magento-demo: Invalid version string "magento-demo")
Reading composer.json of magetest/magento-behat-extension (cleanup)
Importing branch cleanup (dev-cleanup)
Reading composer.json of magetest/magento-behat-extension (develop)
Importing branch develop (dev-develop)
Reading composer.json of magetest/magento-behat-extension (feature/Behat3)
Skipped branch feature/Behat3, "https://api.github.com/repos/MageTest/BehatMage/contents/composer.json?ref=f6488fddf91e68b4bc6c31e91eef928d2ee9fbcc" does not contain valid JSON
Parse error on line 14:
...2-driver": "*", }, "require-dev"
---------------------^
Expected: 'STRING' - It appears you have an extra trailing comma
Reading composer.json of magetest/magento-behat-extension (feature/Product-image-fixture)
Importing branch feature/Product-image-fixture (dev-feature/Product-image-fixture)
Reading composer.json of magetest/magento-behat-extension (feature/created-at-fix)
Importing branch feature/created-at-fix (dev-feature/created-at-fix)
Reading composer.json of magetest/magento-behat-extension (feature/direct-magento-driver-proof-of-concept)
Importing branch feature/direct-magento-driver-proof-of-concept (dev-feature/direct-magento-driver-proof-of-concept)
Reading composer.json of magetest/magento-behat-extension (feature/enhanced-route-excpetion)
Importing branch feature/enhanced-route-excpetion (dev-feature/enhanced-route-excpetion)
Reading composer.json of magetest/magento-behat-extension (feature/exception-thrown-if-sku-is-missing)
Importing branch feature/exception-thrown-if-sku-is-missing (dev-feature/exception-thrown-if-sku-is-missing)
Reading composer.json of magetest/magento-behat-extension (feature/exceptions-thrown-from-fixtures)
Importing branch feature/exceptions-thrown-from-fixtures (dev-feature/exceptions-thrown-from-fixtures)
Reading composer.json of magetest/magento-behat-extension (feature/fix-date-issue-for-product-fixture)
Importing branch feature/fix-date-issue-for-product-fixture (dev-feature/fix-date-issue-for-product-fixture)
Reading composer.json of magetest/magento-behat-extension (feature/licensing)
Importing branch feature/licensing (dev-feature/licensing)
Reading composer.json of magetest/magento-behat-extension (feature/refactor)
Importing branch feature/refactor (dev-feature/refactor)
Reading composer.json of magetest/magento-behat-extension (feature/spec-magento-context-use-of-fixture-factory)
Importing branch feature/spec-magento-context-use-of-fixture-factory (dev-feature/spec-magento-context-use-of-fixture-factory)
Reading composer.json of magetest/magento-behat-extension (feature/travis)
Importing branch feature/travis (dev-feature/travis)
Reading composer.json of magetest/magento-behat-extension (master)
Importing branch master (dev-master)
This exception is thrown when trying to use MinkContext in a subclass of MagentoContext.
In this scenario:
behat.yml
default:
formatter:
name: pretty
context:
class: MyMagentoContext
parameters:
base_url: http://example.dev
extensions:
MageTest\MagentoExtension\Extension:
base_url: "http://example.dev"
Behat\MinkExtension\Extension:
base_url: http://example.dev
goutte:
server_parameters:
HTTP_HOST: %behat.mink.base_url%
sahi: ~
customer:
context:
class: CustomerUserContext
parameters:
base_url: http://example.dev
admin:
context:
class: AdminUserContext
parameters:
base_url: http://example.dev
module:
context:
class: ModuleContext
parameters:
base_url: http://example.dev
WHERE MyMagentoContext is in composer autoload and have following constructor:
class MyMagentoContext extends MagentoContext
{
private $output;
public function __construct(array $parameters)
{
$this->useContext('mink', new MinkContext);
}
and AdminUserContext is defined as follow
use Behat\Behat\Exception\PendingException;
use Behat\Gherkin\Node\TableNode;
use MageTest\MagentoExtension\Context\MagentoContext;
class AdminUserContext extends MyMagentoContext
{
/**
* @Given /^I am on the dashboard after logging in with "([^"]*)" and "([^"]*)"$/
*/
public function iAmOnTheDashboardAfterLoggingInWithAnd($username, $password)
{
$this->getSession()->visit($this->getMinkParameter('base_url') . '/admin');
$this->getSession()->getPage()->fillField('username', $username);
$this->getSession()->getPage()->fillField('login', $password);
$this->getSession()->getPage()->pressButton('Login');
$this->iCloseMessagePopUp();
}
/**
* @Given /^I close message pop up$/
*/
public function iCloseMessagePopUp()
{
$this->getSession()->wait(2000);
$function = <<<JS
(function(){
closeMessagePopup();
})()
JS;
return $this->getSession()->getDriver()->evaluateScript($function);
}
}
WHEN I run command
bin/behat features/admin --profile admin
I get
[Behat\Behat\Exception\RedundantException]
Step "/^(?:|I )am on "(?P<page>[^"]+)"$/" is already defined in AdminUserContext::iAmOn()
AdminUserContext::iAmOn()
Behat\MinkExtension\Context\MinkContext::visit()
To make it all working I need to remove iAmOn from MagentoContext class. Maybe it should be renamed?
Thanks
Add any missing or partially implemented context.
I have been working on writing some tests for a shipping module we have developed for a customer.
Now everything works fine, but one thing I was not able to figure out yet is how we should set the system up to test multiple Magento versions.
We could use modman/composer to install all Magento versions and drop in the module. But I think in this case we would still only be able to test 1 version at a time. Because of the PSR-0 autoloading mapping done in the composer.json file.
So my question is: does anyone have experience with setting up testing for multiple Magento versions using Composer? Maybe to even install the entire Magento installation using it? (we would like to use Composer because it's definitely becoming a solid industry standard)
Edit: also, the tests are not included in the source code of the module, although this is done in this implementation: https://github.com/magento-hackathon/MageBehat What are the pro's/con's? Any thoughts on this?
Many thanks in advance!
Create a project on Travis and start continuous integration for the projects in the organisation
I failed to create a new category with MageTest.
Code to reproduce issue:
$fixtureGenerator = $this->getMainContext()->getFixture('category');
$defaultStoreId = 1;
$parentCategoryId = 1;
$categoryData = array(
'name' => 'Behat Test',
'is_active' => '1',
'meta_description' => 'Test description.',
'store_id' => $defaultStoreId,
'path_ids' =>
array (
$parentCategoryId,
)
);
$fixtureGenerator->create($categoryData);
Actual result:
I get the following error message:
"meta_description is not yet defined as an attribute of Category"
Expected result:
A new category created with the name "Behat Test".
Add a registry to the config manager to provide functionality to restore state after scenario
When I delete a product from backend, then search for this product my site just crashes. Also it is displaying disabled products. How to solve this?
Update any license file and declaration
When I try to execute bin/behat it get this exception, I do have the base_url configured in my behat.yml file.
[Symfony\Component\Config\Definition\Exception\InvalidConfigurationException]
Unrecognized option "base_url" under "testwork.magento"
Am I missing something there?
Hi, I just installed Behat for Magento and started to create my first Behat Test but when I use the MagentoContext, I encounter this error:
PHP Fatal error: Call to a member function customerLogin() on a non-object in /var/www/sf/main/magento/vendor/magetest/magento-behat-extension/src/MageTest/MagentoExtension/Context/MagentoContext.php on line 104
Here's my behat.yml:
default:
paths:
features: features
bootstrap: features/bootstrap
annotations:
paths:
features: features/annotations
closures:
paths:
features: features/closures
extensions:
MageTest\MagentoExtension\Extension:
base_url: "http://avanti.magento.main.sf.devs.ppm.galilee.fr"
It looks like my behat.yml is never read
And here is my directory layout:
project-dir
├── behat.yml
├── bin
│ └── behat
├── composer.json
├── composer.lock
├── features
│ ├── bootstrap
│ └── ...
├── app
├── downloader
├── index.php
├── js
├── skin
├── var
└── ...
└── vendor
├── autoload.php
├── behat
├── magetest
└── ...
Any specified store view will be overridden by MageTest\MagentoExtension\Fixture\Product::create()
Is support for Magento 2 planned? Any thoughts on what would be needed to get there?
I have a behat test for the Customer-Registration in a Magento-Shop (1.8).
In order to rerun the test as often as I want
As a developer I want the Test to clear the generated user account in a scenario hook
Possible Solution:
/**
* @param $event
*
* @BeforeScenario
*/
public function before($event) {
if ('Customer Register' == $event->getScenario()->getTitle()) {
// Delete the TestCustomer if exists.
$customer = Mage::getModel('customer/customer')->loadByEmail('[email protected]');
$customer->delete();
}
}
BUT this does not work.
Then I move the code into a Stepdefinition it works. :(
After each scenario the fixtures should be cleaned up again.
The config fixture step provides the ability to specify a config scope (that is "default", "website" or "store"). For example:
When I set config value for "some/config/path" to "1" in "store" scope
The problem is, to be usable with anything but "default", a scope identifier needs to be specified, for example as follows:
When I set config value for "some/config/path" to "1" in "store" "usa" scope
In the table core_config_data
the scope ID is stored as an integer ID, using 0
for the "default" scope.
To make this more reusable the scope ID should be specifiable as a website or store view code.
References:
MageTest\MagentoExtension\Context\MagentoContext::iSetConfigValueForScope($path, $value, $scope)
MageTest\MagentoExtension\Service\ConfigManager::setCoreConfig($path, $value, $scope)
MageTest\MagentoExtension\Service\Config\CoreConfig::set($path, $value, $scope)
Thinking about it, I'm not sure how using behatmage with a remote (virtual) machine setup would work. Mage::app(); would still be instantiated locally which would quite make sense as you want to test your code in your isolated environment (vagrant machine).
Running behat from within my vagrant machine doesnt feel like an option.
What are your thoughts?
Hi, I have just followed your tutorial to setup magento with behat. After I added this in my behat.yml :
default:
extensions:
MageTest\MagentoExtension\Extension:
base_url: "http://mywebsite.local.com"
Then, I executed bin/behat and I got this error in my terminal :
[ReflectionException]
Class Mage_Core_Model_Config_Data does not exist
I am able to run Behat and test various scenarios that I have defined but when include: MageTest\MagentoExtension\Extension: ~ within my behat.yml file I get
SQLSTATE[HY000] [2002] Connection refusedor a redis error if enabling redis in the Magento config.
Connecting to my Magento instance only seems to be an issue when including this module. I am thinking it might be to do with the way i am adding it to behat.yml or the way i installed using composer ("magetest/magento-behat-extension": "dev-develop").
I am using a VM to run my site but am ruling access issues out due to the fact i can connect via a browser or Behat once this module is removed.
Any ideas? I really want to use and contribute to this module, it looks like a great project.
The context MageTest\MagentoExtension\Context\MagentoContext
provides the step definition for I clear the cache
.
This in fact only clears the Magento configuration cache.
It would be useful to be able to do I clear the "block_html" cache
or I clear the complete cache
The class MageTest\MagentoExtension\Service\CacheManager
already provides the method addSection()
.
Reference:
MageTest\MagentoExtension\Context\MagentoContext::theCacheIsClean()
MageTest\MagentoExtension\Service\CacheManager::clear()
MageTest\MagentoExtension\Service\CacheManager::addSection()
MageTest\MagentoExtension\Service\Cache\ConfigurationCache::clear()
Create a document that provides a quick start guide to start using the module and how to start testing with BehatMage and MageSpec
This is a copy of a Skype discussion on the subject:
Marco Debo De Bortoli: I generally prefer to have features and tests separated from the code base. It's a personal preference of course but it's driven by the fact I "need" and easy way to deploy my source code without the tests suite. Tests are not required by application to work.
Features and tests are of course helpful and they clearly describe more or less what the module does... again not relevant outside of a development scenario...
Vinai Kopp: I can follow that absolutely.
The other approach only makes sense from a Magento module developers perspective
They have a Module centric view. Adding a module to a system should simply add all required components, including any tests. That way interoperability with other extensions by different authers can better be ensured
Since there is no "standard" directory setup outside of the Magento base dir, they like to put all files that belong to their module into that modules directory
Jakub Zalas: if module is a reusable thing, i'd opt for having tests in the module folder
[21.05.13 12:06:19] Marco Debo De Bortoli: Yes I can see that somehow and it's also the way Mage2 is taking making everything self-contained
since it can be taken out of the project and installed in another one
Vinai Kopp: Yes, it is true what you are saying in regards to Mage2
Marco Debo De Bortoli: @jakub: Modules are all reusable else where and there are tools like modman which helps in the process
_Vinai Kopp: So BehatMage using app/code/[codepool]/[NameSpace]/[Module]/features
would perfectly suit that approach.
But it should only use modules that have been activated in app/etc/modules
For that reason it makes sense (and also follows the "magento" way of thinking), that every module that offers BehatMage features should add it's node to the etc/config.xml file
something like
<behat>
<features>
<NameSpace_Module/>
</features>
</behat>
Marco Debo De Bortoli: Something to definitely look into and the same should go for specs and such
Create a document that list the goals of the project and the features that will be added over time.
These items can then be turned into GH Issues and completed.
This project is quite interesting but do you have any status or the list of things need to be done. I can help with some :)
Hi there,
Great work on this. However, I have the following error when following the example in the documentation here.
F---(::) failed steps (::)
- Invalid entity_type specified: catalog_product
In stepGiven the following products exist:'. # AdminUserContext::theProductsExist() From scenario
Turn off reviews per product'. # features\admin_user_manages_review_visibility.feature:6
Of feature `Admin User can manage review visibility'. # features\admin_user_manages_review_visibility.feature1 scenario (1 failed)
4 steps (3 skipped, 1 failed)
0m0.109s
any help appreciated :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.