olexale / bdd_widget_test

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

Custom `stepFolderName` Generates Files Only in `test` Folder #80

Open AntoniKwok opened 5 months ago

AntoniKwok commented 5 months ago

When specifying a custom stepFolderName in build.yaml, the generated dart files are unexpectedly created in the test folder instead of the intended directory (where the feature files belong, e.g integration_test). Is it possible when set the stepFolderName it will generate to the integration_test?

Thanks in advanced!

olexale commented 5 months ago

The framework was created and optimized for widget tests, so the assumption was that if you have integration tests then you probably have unit/widget tests as well and you want to reuse the same steps. Having steps under the test folder shouldn't create any issues except for the inconvenience that you write tests in one folder and modify steps in another, however, if you want to fix that, you may use a relative path in the stepFolderName parameter, i.e. instead of

stepFolderName: step

you may write

stepFolderName: ./step

Clearly, if you have a complex folder structure in tests, you may put ../../ or whatever path makes sense.

AntoniKwok commented 4 months ago

Hi @olexale, Thank you for the answer! I have tried this out and it didn't work well in my case. If I use ../../ I need to have a certain level for each feature file.

Example:

Screenshot 2024-07-02 at 08 56 41

This will create 2 step folder:

Just wondering if we could add testFolderName as an attribute in the build.yaml config

olexale commented 4 months ago

I thought a lot about your proposition. I'm not sure whether it's a good idea to provide too much flexibility to package users as they may do completely wrong stuff. The package was (and still is) optimized for widget tests, that's why it generates everything under the test folder, and integration_test was rather a "why not" bonus on top of that.

However, I see that many users use the package for integration tests only, and I admit that it looks weird that steps are generated in an unexpected place for that case.

The package already has a few special cases to treat integration tests in a special way, and I'm not a fan of that. To avoid making more special cases, I think it might be sufficient if the package generates steps in a folder outside of test.

I made a draft with that. To test the implementation, specify the dependency to the plugin like that:

dev_dependencies:
  bdd_widget_test:
    git:
      url: https://github.com/olexale/bdd_widget_test.git
      ref: feature/absolute_path_to_steps

and then add the following flag in the build.yaml file (or bdd_options.yaml):

stepFolderIsUnderTestFolder: false

Would you please test it and provide your feedback?

AntoniKwok commented 4 months ago

Hi @olexale , Thank you for considering my request.

I tried, but it seems like can't find the reference got ambiguous argument 'feature/absolute_path_to_steps': unknown revision or path not in the working tree.

olexale commented 4 months ago

Ah, right, apologies. Please try now.

olexale commented 3 months ago

Hello, @AntoniKwok. Did you have a chance to try the modified plugin?