Skip to main content

Scenario Context via Context Injection v/s Context Classes via Context Injection

Comments

3 comments

  • Andreas Willich

    Use context classes. The handling of the string keys of the dictionary on the ScenarioContext is a pain.

    Also, you always have to cast. And not only think about the first time when you introduce it. Think about refactoring. 

    And use multiple classes. You won't use them all at the same time.

    0
  • sandeep hegde

    Thanks for the quick feedback Andreas.

    Is there any best practice with respect to creation of Context Classes?

    1) In our repo, we are creating Step Definition files based on Domain Object (as recommended in this article: Step Organization - Cucumber Documentation). For example, in a Curriculum Vitae application, we might have:

    • EmployeeStepDefinitions.java
    • EducationStepDefinitions.java
    • ExperienceStepDefinitions.java
    • AuthenticationStepDefinitions.java
    Should I create context class for each Domain Object. For ex: EmployeeContext, EducationContext, ExperienceContext and AuthenticationContext?
     
    0
  • Andreas Willich

    We recommend structuring the steps to go with which functionality of the application is tested.

    Gáspár Nagy explains this very good in lesson 3 of the SpecFlow/BDD Masterclass. You can watch it in our SpecFlow School at https://specflow.org/school/bdd-masterclass/.

    This lesson has a whole topic about state sharing.

    0

Please sign in to leave a comment.

Powered by Zendesk