olexale / bdd_widget_test

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

[Proposal] Add a comment above the created step. #53

Closed lsaudon closed 11 months ago

lsaudon commented 11 months ago

This would make it easy to find step in dart code.

A file with this

    Scenario Outline: Plus button increases the counter
        Given the app is running

Becomes that.

import 'package:flutter_test/flutter_test.dart';
import 'package:dummy_yaml/main.dart';

/// the app is running
Future<void> theAppIsRunning(WidgetTester tester) async {
  final widget = MyApp();
  await tester.pumpWidget(widget);
}
olexale commented 11 months ago

I'd expect some help from IDE here, i.e. when you type tair it should be smart enough to match it with the file named the_app_is_running.dart.

If you use search, things might become tricker when the step has parameters:

Given {2} plus {2} is equal {4}

Will give

/// plus is equal

or

/// {2} plus {2} is equal {4}

comment (depends on how you propose to handle parameters). Both of these comments might not help you when you are searching for something, as in the first case parameters are missing and if you ignore parameters — just search for plusisequal instead of plus is equal, and in the second case you'll need to know parameter values, which is unlikely is useful.

We may still add a raw line as a documentation comment to generated generic steps, not for search but for documentation purposes, if you see a value in it.

lsaudon commented 11 months ago

I agree with the idea of using the IDE to go directly to the step.

Yes, it may not be possible in some cases.

For me, I'd put the step in raw like /// {2} plus {2} is equal {4}.

I'm aware that it's not perfect, but it gives an alternative to the IDE solution.

PS: I'll have to see if it's not too complicated to make a vscode extension.

olexale commented 11 months ago

It should be straightforward to add such a documentation comment as the raw step line is already a parameter in GenericStep.

lsaudon commented 11 months ago

Yes, I don't think it's complicated. I can do it.