0

I have 2 Features 1. User Creation 2. User Enrollment both are separate and have multiple scenarios. 2nd Feature is dependent on 1st one, so when I run the 2nd Feature directly then how this feature checks the 1st Feature is already run and user created. I am using database in which creation status column (True/False) tells if user has been created or not. So, I want if i run the 2nd feature before that it runs the 1st feature for user creation.

  • Although not a direct answer to your question - I think it is highly related; Features are just a "level" up from Scenarios, and equally (I believe) should be able to be run completely independent from other Features. Read more here: [link](http://stackoverflow.com/questions/11407894/bdd-should-each-scenario-be-self-contained) – SaxonMatt Jul 10 '12 at 15:29

2 Answers2

1

In general, it is considered a very bad practice to have dependencies between tests and a specially features. Each test/scenario should have its own independent setup.

If your second feature depends on user creation, you could just add another step to you scenarios, e.g. "When such and such user is created."

If all scenarios under one feature share common content, you could move it up under a Background tag. For example:

Feature: User Enrollment

Background Given such and such user

Scenario When ... And ... Then...

Scenario When ... And ... Then...

Void Ray
  • 9,849
  • 4
  • 33
  • 53
  • +1 Putting "Given such and such a user" in the Background section seems like the correct way to go to me. – ngm Jul 12 '12 at 10:35
0

I used reflection

  1. Find all Types with a DescriptionAttribute (aka Features)
  2. Find their MethodInfos with a TestAttribute and DescriptionAttribute (aka Scenarios)
  3. Store them to a Dictionary
  4. Call them by "Title of the Feature/Title of the Scenario" with Activator.CreateInstance and Invoke

You have to set the (private) field "testRunner" according to your needs of course.

Andulanus
  • 21
  • 3