Increase behat performance with drush driver

為{幸葍}努か 提交于 2020-01-06 19:29:12

问题


I am running behat inside vagrant in a drupal installation. When I use the drush driver, in order to authenticate an admin for example, the test runs extremelly slow(2'). My behat.yml is:

default:
  suites:
    default:
      contexts:
        - FeatureMinkContext
        - FeatureContext:
        - "/vagrant/images/behat"
        - 813
        - 1855
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\DrushContext
    extensions:
      Behat\MinkExtension:
      selenium2: ~
      javascript_session: 'selenium2'
      browser_name: firefox
      base_url: http://solar.com/  # Replace with your site's URL
    Drupal\DrupalExtension:
      blackbox: ~
      region_map:
        search: ".form-search"
      api_driver: 'drush'
      drush:
        root: /vagrant/drupal
      selectors:
        message_selector: '.messages'
        error_message_selector: '.messages.messages-error'
        success_message_selector: '.messages.messages-status'
      drupal:
        # Replace with your real Drupal root.
        drupal_root: "/vagrant/drupal"

Test structure:

@javascript @api
Feature: Tests google maps and pois
@maps
Scenario: My tests
  Given I am logged in as a user with the "administrator" role
  ...

回答1:


Didn't used drush but,

The first thing you need to do is to identify the bottleneck, maybe the server is slow, maybe you are using some method that is slow or maybe you have some waits that are not right.

Definitely something is wrong if it takes 2' for an admin authentication.

Run the scenario, debug until you narrow to the method with the issue.

Some other things you could do are:

  • never use blind waits, only conditional waits
  • if you have to fill large forms try using a javascript method for fill, it will be very fast
  • try different browsers, in my case chrome is slightly faster



回答2:


Is it a local site setup? If yes, then behat scripts for Drupal do run a bit slow on local as compared to running it on the actual site. I have faced this in almost every project. For me, the first step which is admin authentication takes upto 5 minutes at times. Increasing the RAM size reduces this problem to some extent.



来源:https://stackoverflow.com/questions/39273927/increase-behat-performance-with-drush-driver

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!