Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change test to flutter_test on the 'An introduction to unit testing' page #5372

Closed
hk6an6 opened this issue Mar 1, 2021 · 7 comments · Fixed by #8950
Closed

Change test to flutter_test on the 'An introduction to unit testing' page #5372

hk6an6 opened this issue Mar 1, 2021 · 7 comments · Fixed by #8950
Assignees
Labels
a.cookbook Relates to a cookbook recipe or guide e1-hours Effort: < 8 hrs from.page-issue Reported in a reader-filed concern p2-medium Necessary but not urgent concern. Resolve when possible. test.general Relates to unit, integration, perf testing

Comments

@hk6an6
Copy link
Contributor

hk6an6 commented Mar 1, 2021

Page URL: https://docs.flutter.dev/cookbook/testing/unit/introduction
Page source: https://github.com/flutter/website/tree/master/src/docs/cookbook/testing/unit/introduction.md

Description of issue:

The lines 35 to 45 are misleading and will not yield working code. The documentation introduces 2 problems that will be confusing for beginners:

  1. When adding dependencies, the name of the file to modify is missing. It should be pubsec.yaml.

  2. When suggesting what to put in the file the documentation in line 43 recommends test: <latest_version> - which will not compile. Instead the entry needs to look like this:

# in pubsepc.yaml:
dev_dependencies:
  flutter_test:
    sdk: flutter
@sfshaza2 sfshaza2 added e2-days Effort: < 5 days p2-medium Necessary but not urgent concern. Resolve when possible. labels Mar 10, 2021
@arps18
Copy link

arps18 commented May 15, 2021

Hey @sfshaza2 can I work on the issue?

@sfshaza2
Copy link
Contributor

Yup! But does this page use code excerpts? If so, that requires special handling.

@atsansone atsansone added from.page-issue Reported in a reader-filed concern a.cookbook Relates to a cookbook recipe or guide tests test.general Relates to unit, integration, perf testing and removed tests labels May 19, 2023
@atsansone atsansone changed the title 'An introduction to unit testing' page issue Change test to flutter_test on the 'An introduction to unit testing' page May 23, 2023
@atsansone
Copy link
Contributor

This should replace:

Change lines 18 to 19. To clarify, the page should state:

You need the [`flutter_test`](https://pub.dev/packages/test).
It contains the [`test`](https://api.flutter.dev/flutter/flutter_test/flutter_test-library.html)
package and provides utilities for testing widgets.

Replace test with flutter_test throughout.

@atsansone atsansone added e1-hours Effort: < 8 hrs and removed e2-days Effort: < 5 days labels May 23, 2023
@atsansone atsansone self-assigned this May 23, 2023
@brianegan
Copy link
Contributor

Sure, no problems here. My goal was to indicate that unit tests are separate from flutter tests, and that there are many cases where you may want to test business logic independent of Flutter. Therefore, using raw test package is better IMO so you do not accidentally introduce Flutter dependencies in your business logic layer (which should operate independently of any GUI -- at the time, AngularDart was still officially supported and I was working on projects where sharing logic between Flutter and AngularDart was a requirement).

I don't feel strongly, however, if you think this is a better direction.

@brianegan
Copy link
Contributor

brianegan commented May 25, 2023

Please also see the historical context here: a786092

#2497

Again, these recipes are over 4 years old (maybe closer to 5-6 years old). So these decisions should be revisited.

@atsansone
Copy link
Contributor

Fixed in #8950

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a.cookbook Relates to a cookbook recipe or guide e1-hours Effort: < 8 hrs from.page-issue Reported in a reader-filed concern p2-medium Necessary but not urgent concern. Resolve when possible. test.general Relates to unit, integration, perf testing
Projects
None yet
5 participants