Search code examples
phpcontinuous-integrationbehatmink

Continuous Integration tool for behat


What is the best CI(Continuous Integration) tool for behat and can you provide the steps to configure it. Because i want to run all my features of behat when any one push in git. i.e when something get push in my git A/C the CI will run all my features and the result should be send via email like jenkins.


Solution

  • You shouldn't run automation on every push because if you will have a suite that lasts more than the interval between 2 pushes then the results from one run can affect the results from the other.

    I think you can use any CI tool that dev's are using.

    If you are using Jenkins then you can create a regular job with:

    Project name - any name Description - description of the job, like running automation suite
    Discard old builds - Log Rotation ; max builds to keep at least 10, depending on how much you run and if you get the email with results + raport
    This build is parameterized - add parameters like: GIT_BRANCH for the branch of the git, SUITE_TYPE if you want to configure multiple suites like regression, smoke and other parameters
    Execute concurrent builds if necessary - check it if you want to run in parallel from the same job on multiple environments
    Source Code Management - select git and add repository url an credentials; Branches to build ${GIT_BRANCH}

    Build section
    Execute shell - add commands to change directory to your behat directory if needed, command to install behat, command to run behat

    # change directory if needed
    cd workspace/automationDirectory
    # download composer.phar if needed, depending on how you are installing behat
    curl -sS https://getcomposer.org/installer | php
    # install behat
    php composer.phar install --prefer-dist
    # set profile if needed
    BEHAT_PROFILE = ""
    # add logic to create filters
    if [ "$SUITE_TYPE" = "regression" ]; then
    BEHAT_TAGS="@regression"
    
    elif [ "$SUITE_TYPE" = "smoke" ]; then
    BEHAT_TAGS="@smoke"
    
    else
    BEHAT_TAGS="@fastRun"
    fi
    
    bin/behat --profile="$BEHAT_PROFILE" --tags="$BEHAT_TAGS"

    If yo need to use in CI you should find some online documentation to triger this build from another. For email you could use a Jenkins plugin.
    Anyway this question is to broad, you should try small parts and ask specific questions.