How to disable a function in specflow (Gherkin) without deleting this function?

I have some SpecFlow functions (using Gherkin syntax) and I would like to temporarily disable this function to prevent its tests from running?

Is there an attribute with which I can mark this function? I assume that something that works with Cucumber may also work with SpecFlow.

+54
cucumber gherkin specflow
Jun 03 '10 at 13:44
source share
4 answers

You can mark this function with @ignore tag:

@ignore @web Scenario: Title should be matched When I perform a simple search on 'Domain' Then the book list should exactly contain book 'Domain Driven Design' 
+76
Jun 03 2018-10-06
source share

In the latest version of Specflow, you must also indicate the reason with the tag, for example:

 @ignore("reason for ignoring") 

EDIT: For some reason, it breaks into spaces, but this works:

 @ignore("reason") 
+7
May 4 '16 at 21:03
source share

As jbandi says, you can use the @ignore tag.

The tag can be applied to:

  • one scenario
  • full function

Given that NUnit is a test provider, the result of the generated code is an insert

[NUnit.Framework.IgnoreAttribute ()]

to a method or class.

+1
Oct 18 '13 at 12:15
source share
 Feature: CheckSample @ignored Scenario Outline: check ABC #checkout.feature:2 Given I open the applciation When I enter username as "<username>" And I enter password as "<password>" Then I enter title as "<title>" Examples: | username | password | | dude | daad | 

consider the above as a file of the function "CheckSample.feature"

And below is your step file, this is just a partial file:

 public class Sampletest { @Given("^I open the applciation$") public void i_open_the_applciation() throws Throwable { // Write code here that turns the phrase above into concrete actions //throw new PendingException(); } 

Now the running file will be below:

 @RunWith(Cucumber.class) @CucumberOptions( plugin = {"pretty", "html:target/reports", "json:target/reports/cucumber-report.json"}, monochrome = true, tags = {"~@ignored"} ) public class junittestOne { public static void main(String[] args) { JUnitCore junit = new JUnitCore(); Result result = junit.run(junittestOne.class); } } 

It is important to note that the text "@ignored" in the function file is mentioned in the CucumberOptions (tags) in the class file "junittestone". Also, make sure that you have all the relevant jar files for both cucumbers, cucumbers, Junit and other cans available in your project, and you have imported them into your step definitions (class).

Due to "ignoring" the script will be skipped during the execution of the tests.

0
Jun 01 '17 at 15:55
source share



All Articles