Skip to content

Commit ad5401e

Browse files
committed
Update README and configuration to support custom step folder paths
1 parent c458db1 commit ad5401e

6 files changed

Lines changed: 18 additions & 11 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,15 @@ targets:
429429

430430
Since Patrol version 3.0.0, `IntegrationTestWidgetsFlutterBinding.ensureInitialized` must not be called. Set `includeIntegrationTestBinding` to `false`.
431431

432+
### I don't like that the plugin creates steps under `test` folder. How to change that?
433+
434+
You may set a relative path in the `build.yaml` file (see the `example` folder):
435+
```yaml
436+
relativeToTestFolder: false
437+
stepFolderName: integration_test/steps # if you want to have steps in the integration_test folder
438+
hookFolderName: integration_test/bdd_hooks # if you want to have hooks in the integration_test folder
439+
```
440+
432441
## Contributing
433442

434443
If you find a bug or would like to request a new feature, just [open an issue](https://github.com/olexale/bdd_widget_test/issues/new). Your contributions are always welcome!

example/build.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ targets:
1010
options:
1111
includeIntegrationTestBinding: false # if false, integration test will not include binding; default is true
1212
stepFolderName: step # this trick is required to share steps between widget and integration tests
13-
# stepFolderIsUnderTestFolder: false # if false, steps will be generated in the root of the package; default is true
13+
# relativeToTestFolder: false # if false, steps will be generated in the root of the package; default is true
1414
# testMethodName: customTestMethodName
1515
include: package:bdd_widget_test/bdd_options.yaml # you may add defaul external steps with this line
1616
externalSteps: # or list only steps that you need

lib/src/generator_options.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ class GeneratorOptions {
1313
String? testMethodName,
1414
List<String>? externalSteps,
1515
String? stepFolderName,
16-
bool? stepFolderIsUnderTestFolder,
16+
bool? relativeToTestFolder,
1717
String? testerType,
1818
String? testerName,
1919
bool? addHooks,
2020
String? hookFolderName,
2121
this.include,
2222
bool? includeIntegrationTestBinding,
2323
}) : stepFolder = stepFolderName ?? _stepFolderName,
24-
stepFolderIsUnderTestFolder = stepFolderIsUnderTestFolder ?? true,
24+
relativeToTestFolder = relativeToTestFolder ?? true,
2525
testMethodName = testMethodName ?? _defaultTestMethodName,
2626
testerType = testerType ?? _defaultTesterType,
2727
testerName = testerName ?? _defaultTesterName,
@@ -37,8 +37,7 @@ class GeneratorOptions {
3737
testerName: json['testerName'] as String?,
3838
externalSteps: (json['externalSteps'] as List?)?.cast<String>(),
3939
stepFolderName: json['stepFolderName'] as String?,
40-
stepFolderIsUnderTestFolder:
41-
json['stepFolderIsUnderTestFolder'] as bool?,
40+
relativeToTestFolder: json['relativeToTestFolder'] as bool?,
4241
addHooks: json['addHooks'] as bool?,
4342
hookFolderName: json['hookFolderName'] as String?,
4443
include: json['include'] is String
@@ -49,7 +48,7 @@ class GeneratorOptions {
4948
);
5049

5150
final String stepFolder;
52-
final bool stepFolderIsUnderTestFolder;
51+
final bool relativeToTestFolder;
5352
final String testMethodName;
5453
final String testerType;
5554
final String testerName;
@@ -101,8 +100,7 @@ GeneratorOptions merge(GeneratorOptions a, GeneratorOptions b) =>
101100
a.testerName != _defaultTesterName ? a.testerName : b.testerName,
102101
stepFolderName:
103102
a.stepFolder != _stepFolderName ? a.stepFolder : b.stepFolder,
104-
stepFolderIsUnderTestFolder:
105-
a.stepFolderIsUnderTestFolder && b.stepFolderIsUnderTestFolder,
103+
relativeToTestFolder: a.relativeToTestFolder && b.relativeToTestFolder,
106104
externalSteps: [...a.externalSteps, ...b.externalSteps],
107105
addHooks: a.addHooks || b.addHooks,
108106
hookFolderName: a.hookFolderName != _hookFolderName

lib/src/util/get_test_folder_name.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const _testFolderName = 'test';
55

66
/// Returns the folder where step folder is located.
77
String getPathToStepFolder(GeneratorOptions options) {
8-
if (options.stepFolderIsUnderTestFolder) {
8+
if (options.relativeToTestFolder) {
99
return _testFolderName;
1010
}
1111
return fs.currentDirectory.path;

test/feature_generator_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void main() {
5959
test('existing step outside test folder should be found', () async {
6060
const bddOptions = '''
6161
stepFolderName: my_steps
62-
stepFolderIsUnderTestFolder: false
62+
relativeToTestFolder: false
6363
''';
6464
fs.file('bdd_options.yaml')
6565
..createSync()

test/step_folder_name_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ void main() {
102102
input: featureFile,
103103
generatorOptions: const GeneratorOptions(
104104
stepFolderName: 'custom_steps',
105-
stepFolderIsUnderTestFolder: false,
105+
relativeToTestFolder: false,
106106
),
107107
);
108108
expect(feature.dartContent, expectedFeatureDart);

0 commit comments

Comments
 (0)