olexale / bdd_widget_test

A BDD-style widget testing library
MIT License
101 stars 30 forks source link

Cannot share steps between feature files with different hierarchy level #42

Closed GuillaumeMorinQc closed 1 year ago

GuillaumeMorinQc commented 1 year ago

In our project we would like to organize our feature files like this:

Since feature files does not share the same level hierarchically, multiple step folders are created even with a relative stepFolderName. Result :

Can we have an option, so we can use a path relative to the project folder to generate steps independently of the feature files hierarchy ?

DerJojo11 commented 1 year ago

Funny, was going to write a similar ticket today.

We are having the same issue. We want to share one steps folder, thus we need an option to set a relative path, where all steps are defined.

With the current "hack" from the example it is not possible to map the above folder structure.

Something like this:

bdd_widget_test|featureBuilder:
        options:
            stepFolderPath: tests/steps
GuillaumeMorinQc commented 1 year ago

Either that, an option to specify that this path is relative to the root of the project or an expression like "{cwd}" at the beginning to resolve the current directory

olexale commented 1 year ago

That would be a breaking change, but we probably may introduce the syntax @DerJojo11 mentioned. I will have a look at this on the weekend. Thanks for raising this issue!

olexale commented 1 year ago

This should work in 1.6.0. If the step folder name starts with ./ or ../ - bdd_widget_test will treat it as relative to the feature folder path (the behavior prior to 1.6.0). If not - it will look for a folder under the test folder.

So, if you want to have a single steps folder for the package, you may set it up like this:

stepFolderPath: steps

Would you please test the new feature?

DerJojo11 commented 1 year ago

Awesome! Thanks!

So I tried it out and it works good!

My Folder Structure looks like this:

With this structure, I wish to have a folder structure like this:

Right now, I can set the folderPath for it to:

stepFolderPath: steps

and remove the stepFolderName. Then, this solution won't work. We are creating then multiple step folder in each feature.

But if I use only the

stepFolderName: steps

Then we won't build new step folders. Instead only one Folder under the test fold has been created! This is great! And we can ow use our own folder structure!

Testing the stepFolderPath

Then, I tried testing to change the folder path to something like this:

stepFolderName: all_steps 
stepFolderPath: steps/all_steps

This won't work. Because we know create one all_steps folder under the test folder.

Conclusion

Currently the way via stepFolderPath does not work. Or I did not understand it correctly. But my wish to create a step folder for all tests works fine! So thank you very much for that!

olexale commented 1 year ago

Sorry for the confusion, there is no stepFolderPath parameter, I copy-pasted it from your comment and didn't notice that it is not stepFolderName. My bad 🤦‍♂️

So, you may use the stepFolderName parameter to set both the name and the path and inside the new folder you may use whatever structure you like - put everything in the root of the folder or create sub-folders to match the structure of your test folder.

olexale commented 1 year ago

Do you think we may close the issue?

DerJojo11 commented 1 year ago

Ah ok!

For my part, we can close this issue. 😃

GuillaumeMorinQc commented 1 year ago

It's exactly what we needed