Running behat tests in parallel (in two browser windows)

岁酱吖の 提交于 2019-12-01 09:39:06

问题


I followed this blog as an example and read the ParallerRunner info. When I call bin/behat command, one browser window opens and runs all the tests successfully with the setting below.

symfony/behat.yml

default:
    context:
        class: Site\CommonBundle\Features\Context\FeatureContext
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://symfony.local/app_test.php/'
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

I modified the behay.yml (as shown below) to run some tests in one browser window and some in another window, however it doesn't do that. What it does is, it opens two browser windows but they both run same tests! How can I overcome this issue?

symfony/behat.yml

default:
    context:
        class: Site\CommonBundle\Features\Context\FeatureContext
        parameters:
            output_path: %behat.paths.base%/build/behat/output/
            screen_shot_path: %behat.paths.base%/build/behat/screenshot/
    extensions:
        Behat\Symfony2Extension\Extension:
            mink_driver: true
            kernel:
                env: test
                debug: true
        Behat\MinkExtension\Extension:
            base_url: 'http://symfony.local/app_test.php/'
            files_path: %behat.paths.base%/build/dummy/
            javascript_session: selenium2
            browser_name: firefox
            goutte: ~
            selenium2: ~
        shvetsgroup\ParallelRunner\Extension:
            process_count:  2
    paths:
        features: %behat.paths.base%/src
        bootstrap: %behat.paths.features%/Context

F1:
    filters:
        tags: "@backend"
F2:
    filters:
        tags: "@frontend"

BEHAT TESTS:

This should run in one window:

@frontend
Feature: User Login

  @javascript
  Scenario: I can login to the system
    Given I am on "/login"
    And I login as "user"

This should run in another window:

@backend
Feature: Admin Login

  @javascript
  Scenario: I can login to the system
    Given I am on "/login"
    And I login as "admin"

回答1:


I setup parallel test execution with GNU Parallel and xargs. Also implement consolidated report for all executed features. Details in my article here:
http://parallelandvisualtestingwithbehat.blogspot.com/p/blog-page.html




回答2:


find ./features -name "*.feature" |
  parallel --gnu --halt-on-error=0 -j 3 --keep-order vendor/bin/behat -c src/my_directory/behat.yml

--halt-on-error possibilities are :

  • 0 Do not halt if a job fails. Exit status will be the number of jobs failed. This is the default.

  • 1 Do not start new jobs if a job fails, but complete the running jobs including cleanup. The exit status will be the exit status from the last failing job.

  • 2 Kill off all jobs immediately and exit without cleanup. The exit status will be the exit status from the failing job.

-j 3 : Run 3 jobs in parallel

It work perfectly with selenium.



来源:https://stackoverflow.com/questions/26383870/running-behat-tests-in-parallel-in-two-browser-windows

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