Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How to run a single cucumber file

How to run a single cucumber file

When you develop you Cucumber tests you do need to run single cucumber file. Here is how to run a single cucumber file.

Run single cucumber file in ruby (macOS)
cucumber features/feature_name.feature
Run single cucumber file in ruby (Linux)

If you have a pipeline job you might want to run a single cucumber file in jenkins in headless mode you can configure your pipeline to run a single file rather than running parallel of all tests.

You can simply create a method that calls the run tests method below which determines which set of tests to run based on the build variables.

node(){
   timestamps {
        stage 'Running tests'
         try{
             if ( !env.FEATURE && !env.CUCUMBER_TAG ) {
                              runTests();
                  } else if (env.FEATURE && env.CUCUMBER_TAG) {
                              runfeaturefile();
                              runTags();
                          }
                      else if (env.FEATURE && !env.CUCUMBER_TAG) {
                              runfeaturefile();
                          }
                      else if (!env.FEATURE && env.CUCUMBER_TAG) {
                              runTags();
                   }
      }catch(err) {
                echo "Build failed at ; stage('Running tests')"
                echo err.getMessage();

               }
        }
}

Where run featurefile();:

// run feature/features that are provided into the build
def runfeaturefile(){
    echo "Running feature file"
    def features = env.FEATURE
    List items = Arrays.asList(features.split("\\s*,\\s*"));
    try{
        for (int i = 0; i 

Happy testing!

The post How to run a single cucumber file appeared first on Testingrepository - Talking about selenium , and our passion.



This post first appeared on Testing Repository - Creating Testing, please read the originial post: here

Share the post

How to run a single cucumber file

×

Subscribe to Testing Repository - Creating Testing

Get updates delivered right to your inbox!

Thank you for your subscription

×