bdd_widget_test icon indicating copy to clipboard operation
bdd_widget_test copied to clipboard

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

Open AntoniKwok opened this issue 1 year ago • 6 comments

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!

AntoniKwok avatar Jun 25 '24 10:06 AntoniKwok

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.

olexale avatar Jun 26 '24 07:06 olexale

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:

  • one inside the features folder
  • the other one, outside of the features folder

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

AntoniKwok avatar Jul 02 '24 02:07 AntoniKwok

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?

olexale avatar Jul 06 '24 17:07 olexale

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.

AntoniKwok avatar Jul 10 '24 10:07 AntoniKwok

Ah, right, apologies. Please try now.

olexale avatar Jul 10 '24 15:07 olexale

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

olexale avatar Jul 28 '24 12:07 olexale