Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mark tests explicit in SpecFlow

Tags:

specflow

Is there a way to mark a Specflow test with an "Explicit" attribute? I am aware that a test can be marked with the "Ignore" attribute via the use of the special tag @ignore.

like image 409
stannius Avatar asked Feb 07 '13 19:02

stannius


People also ask

Can we generate reporting using SpecFlow?

In order to start generating reports, you will need the NUnit console to execute the Specflow tests. Install NUnit console by downloading the executable package file for windows here. Download NUnit-Console -3.9.

What is gherkin in SpecFlow?

A single Gherkin scenario is a flow of events through the Feature being described and maps 1:1 with an executable test case for the system. You can have multiple Scenarios in one Feature-file. Feature: Calculator.

How do you ignore a test in SpecFlow?

Ignored Tests Just like with normal unit tests, you can also ignore SpecFlow tests. To do so, tag the feature or scenario with the @ignore tag.


1 Answers

Maybe.

If you look at the generated xxx.feature.cs, you will see that it is defined as

public partial class xxx{...

So you can add another file to your project xxx.partial.cs that contains the other part of your partial definition.

And that's the end of what I know, now for you might be able to do.

In theory you could use the partial class definition and modify it, to make it abstract. Then you could add a derived class where you override the test in question, this would have to be a new as we can't use virtual in the xxx, and add your [Explicit] there.

I have no idea if this will work. You could have all sorts of issues with the abstract not taking, or the test attributes disappearing on the derived class, etc. But maybe it might get you going.

P.S. I'm also not sure this is anything near to good practice. :-)

like image 166
AlSki Avatar answered Sep 20 '22 17:09

AlSki