CucumberJVM: 08 - Cucumber Tags

Tags are just annotations that allow for grouping of feature tests

 

Examples

//        ,tags= {"@RegressionTest, @SmokeTest"} // OR
//        ,tags= {"@RegressionTest","@SmokeTest"} // AND
//        ,tags= {"~@RegressionTest","@SmokeTest"} // ignore filter = 8
        ,tags= {"@SmokeTest"} // filter = 9

Feature

Feature: Free CRM application testing

@RegressionTest
Scenario: Login with correct username and correct password
Given This is a valid login test

@RegressionTest @End2End
Scenario: Login with incorrect username and correct password
Given This is a invalid login test

@RegressionTest
Scenario: Create a contact
Given This is a contact test case

@RegressionTest @End2End
Scenario: Create a deal
Given This is a deal test case

@RegressionTest
Scenario: Create a tasks
Given This is a tasks test case

@RegressionTest @SmokeTest
Scenario: Create a case
Given This is a case test case

@SmokeTest
Scenario: Verify left panel links
Given clicking on left panel links

@SmokeTest
Scenario: Search a deal
Given This is a search deal test

@SmokeTest
Scenario: Search a contact
Given This is a search contact test

@SmokeTest @End2End
Scenario: Search a case
Given This is a search deal test

@SmokeTest
Scenario: Search a task
Given This is a search task test

@SmokeTest
Scenario: Search an email
Given This is a search email test

@SmokeTest
Scenario: Search a docs
Given This is a search docs test

@SmokeTest @End2End
Scenario: Search a forms
Given This is a search forms test

@End2End
Scenario: Validate a report
Given This is a report test

@End2End @RegressionTest
Scenario: Application Logout
Given This is a logout test

 


Definition

package stepDefinitions;

import cucumber.api.PendingException;
import cucumber.api.java.en.Given;

public class TaggingStepDefinition {

    @Given("^This is a valid login test$")
    public void this_is_a_valid_login_test(){

    }

    @Given("^This is a invalid login test$")
    public void this_is_a_invalid_login_test(){

    }

    @Given("^This is a contact test case$")
    public void this_is_a_contact_test_case(){

    }

    @Given("^This is a deal test case$")
    public void this_is_a_deal_test_case(){

    }

    @Given("^This is a tasks test case$")
    public void this_is_a_tasks_test_case(){

    }

    @Given("^This is a case test case$")
    public void this_is_a_case_test_case(){

    }

    @Given("^clicking on left panel links$")
    public void clicking_on_left_panel_links(){

    }

    @Given("^This is a search deal test$")
    public void this_is_a_search_deal_test(){

    }

    @Given("^This is a search contact test$")
    public void this_is_a_search_contact_test(){

    }

    @Given("^This is a search task test$")
    public void this_is_a_search_task_test(){

    }

    @Given("^This is a search email test$")
    public void this_is_a_search_email_test(){

    }

    @Given("^This is a search docs test$")
    public void this_is_a_search_docs_test(){

    }

    @Given("^This is a search forms test$")
    public void this_is_a_search_forms_test(){

    }

    @Given("^This is a report test$")
    public void this_is_a_report_test(){

    }

    @Given("^This is a logout test$")
    public void this_is_a_logout_test(){

    }

}

 

 

 


Test Runner

package uc.atmtransaction.Runner;

import org.junit.runner.RunWith;

import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = "src/main/java/Features/tagging.feature"
        ,glue= {"stepDefinitions"}
        ,format= {"pretty","html:test-output","json:json-output/cucmber.json","junit:xml-output/cucumber.xml"}
        ,strict=false
        ,monochrome=true
        ,dryRun=false
//        ,tags= {"@RegressionTest, @SmokeTest"} // OR
//        ,tags= {"@RegressionTest","@SmokeTest"} // AND
//        ,tags= {"~@RegressionTest","@SmokeTest"} // ignore filter = 8
        ,tags= {"@SmokeTest"} // filter = 9
        )

public class TestRunner {

}