SpecFlowOSS / SpecFlow

#1 .NET BDD Framework. SpecFlow automates your testing & works with your existing code. Find Bugs before they happen. Behavior Driven Development helps developers, testers, and business representatives to get a better understanding of their collaboration
https://www.specflow.org/
Other
2.24k stars 754 forks source link

Extract Scenarios from dll #2689

Open javed0211 opened 1 year ago

javed0211 commented 1 year ago

Link to Feature Request

No response

Implementation Idea

Hi Team,

Our company heavily utilizes SpecFlow for testing across various projects. We are currently in the process of developing an end-to-end solution, but our test cases are scattered across multiple repositories. We do not want to go through the process of rewriting them again. We were wondering if there is a way to extract the scenarios from the feature.cs file or dll and use them to build an end-to-end flow.

We have attempted to extract the test steps, but we have not been able to extract the scenarios as a whole. Are there any solutions or methods that can assist us in achieving this goal?

Thanks, Javed Khan

SabotageAndi commented 1 year ago

We include the feature files as resources in the compiled assembly. Does this help you?

javed0211 commented 1 year ago

It might not help us, I guess. How do I choose test cases / scenarios if I add feature files in compiled assembly?

SabotageAndi commented 1 year ago

Ok, then I missunderstood your use case. At which point do you want to have the scenario text? Depending on that, perhaps there is a way to find it.

javed0211 commented 1 year ago

My goal is to use Hangfire to schedule test cases, but I am facing some challenges. I am trying to extract the test cases from various projects' dll or feature.cs files and build a single job for end-to-end testing. While I have been successful in extracting the test methods from the dll files, I am unable to execute them. Additionally, this approach causes issues with 'specflow' hooks not being executed. Furthermore, I attempted to extract methods from feature.cs for each scenario, but this caused the test context to be null. If my explanation is unclear, please let me know and I will provide more information.

SabotageAndi commented 1 year ago

So you want to create your own test runner. If so, bad luck. SpecFlow is written to be used with NUnit, xUnit or MSTest. It is highly integrated with them. One thing are the hooks.

javed0211 commented 1 year ago

No, I dont want to create my test runner. I am using specflow.MsTest in all my projects. I just want to create a bridge between test cases to build end to end test suite.