Can I list all the FeatureInfo of a test project in a BeforeTestRun hook ? #275
-
TL;DR: Is there a way to list all the FeatureInfo or all the feature tags in a BeforeTestRun hook ? Details: I did a web api tests framework using SpecFlow and Reqnoll. Each of my api test Feature has a tag which help me to create a sql server database on the fly. By doing this, I can seed the database depending on the tag and play all my scenarios in a specific data context. These databases are created from EF snapshot at BeforeFeature, it works well but it is slow because the database schema is big. Another problem is that I recreate all the database and seed some default data each time, but just some data varies depending on the Feature. To optimise my database creation, I create a reference database at the BeforeTestRun, create a backup file and then the BeforeFeature can create its own database depending on the reference. It is way faster than my initial approach. It works well on the CI because there is no parallelization, but on local, the features are parallelized and there is concurrency issues because multiple Features try to copy the same file at the same time. So my idea is to list all the feature tags in the BeforeTestRun so I can create all the backups file copies synchronously, and then the BeforeFeature can access to its backup file without concurrency issues. Now my question : Is there a way to list all the FeatureInfo or all the feature tags in a BeforeTestRun hook ? Thanks 🙏 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Unfortunately not. At the time of the test execution start (when we invoke the BeforeTestRun hook), we don't have the information of what tests are going to be executed (because of user defined filters), so we don't know anything neither about the scenario not about the features. What about implementing a classic locking and allow only one backup processing at a time? |
Beta Was this translation helpful? Give feedback.
Unfortunately not. At the time of the test execution start (when we invoke the BeforeTestRun hook), we don't have the information of what tests are going to be executed (because of user defined filters), so we don't know anything neither about the scenario not about the features.
You can access to the loaded test assembly via
ITestAssemblyProvider.TestAssembly
and scan through the classes to find "feature" classes and read the attributes of them in order to get an info of the feature hooks, but it is not guaranteed that they will be needed finally.What about implementing a classic locking and allow only one backup processing at a time?