06
Jan

Working with BDD features/scenarios


@Jackychan
Feature: Sample testng feature

  @FirstTags
  Scenario: Cucumber expressions example
    Given As a User i search for 45 text
    And As a User i search for 60 text
    And I share name of "Sheetal"
    And I share name of "Khan"   
    
  @SecondTags
  Scenario: Cucumber expressions example
    Given As a User i search for 45 text
    And As a User i search for 60 text
    And I share name of "Sheetal"
    And I share name of "Khan"  





#1. Run specific BDD feature:
==============================

@CucumberOptions(plugin = { "pretty", "html:target/html", "json:cucumber.json" }, 
		 strict = true,
		 monochrome = true,
		 features = "src/test/resources/features/first.feature",
		 glue = "stepDefinition")
public class CucumberRunner extends AbstractTestNGCucumberTests {

	// your custom initialization
}


#2. Run all features where scenario(s)/feature(s) is/are tagged with User defined tag (say @Jackychan):
===========================================================================================================

@CucumberOptions(plugin = { "pretty", "html:target/html", "json:cucumber.json" },
				 strict = true,
				 monochrome = true,
				 features = "src/test/resources/features/",
				 glue = "stepDefinition",
				 tags = {"@Jackychan"})
public class CucumberRunner extends AbstractTestNGCucumberTests {


	// your custom initialization
}


#3. Combining tags with OR operator:
======================================

@CucumberOptions(plugin = { "pretty", "html:target/html", "json:cucumber.json" },
				 strict = true,
				 monochrome = true,
				 features = "src/test/resources/features/",
				 glue = "stepDefinition",
				 tags = {"@FirstTags,@SecondTag"})
public class CucumberRunner extends AbstractTestNGCucumberTests {


	// your custom initialization
}


#4. Combining tags with AND operator:
======================================

@CucumberOptions(plugin = { "pretty", "html:target/html", "json:cucumber.json" },
				 strict = true,
				 monochrome = true,
				 features = "src/test/resources/features/",
				 glue = "stepDefinition",
				 tags = {"@FirstTags","@SecondTag"})
public class CucumberRunner extends AbstractTestNGCucumberTests {


	// your custom initialization
}



#5. Ignore specific tags:
===========================

@CucumberOptions(plugin = { "pretty", "html:target/html", "json:cucumber.json" },
				 strict = true,
				 monochrome = true,
				 features = "src/test/resources/features/",
				 glue = "stepDefinition",
				 tags = {"~@FirstTags,@SecondTags"})
public class CucumberRunner extends AbstractTestNGCucumberTests {


	// your custom initialization
}


#6. Execute all tests which are not at all tagged in all the Features
======================================================================
@CucumberOptions(plugin = { "pretty", "html:target/html", "json:cucumber.json" },
				 strict = true,
				 monochrome = true,
				 features = "src/test/resources/features/",
				 glue = "stepDefinition",
				 tags = {"~@FirstTags","~@SecondTags"})
public class CucumberRunner extends AbstractTestNGCucumberTests {


	// your custom initialization
}