Skip to content

Add example test, update example READMEs - #91130

Merged
fluttergithubbot merged 3 commits into
flutter:masterfrom
gspencergoog:add_example_test
Oct 4, 2021
Merged

fluttergithubbot merged 3 commits into
flutter:masterfrom
gspencergoog:add_example_test

Conversation

@gspencergoog

Copy link
Copy Markdown
Contributor

Description

This updates the README.md in examples/api, and adds a "token" test in the test directory, establishing a pattern for writing tests.

I also deleted the README.md in the snippets directory, since it is redundant with the examples one now.

Tests

  • Added a token example test to the examples/api/test directory.

@flutter-dashboard flutter-dashboard Bot added d: examples Sample code and demos c: contributor-productivity Team-specific productivity, code health, technical debt. labels Oct 2, 2021
@google-cla google-cla Bot added the cla: yes label Oct 2, 2021

@HansMuller HansMuller left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM although I'm concerned about creating an implicit test template for examples that relies on golden image testing.

Comment thread examples/api/README.md Resolved
Comment thread examples/api/README.md Resolved
Comment thread examples/api/README.md Resolved
Comment thread examples/api/README.md Resolved
Comment thread examples/api/README.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what "with composition and overrides" refers to here. Can we test layout and (input) behavior?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that you can subclass the examples to override things, or wrap them with something to help test them.

Can we test layout and (input) behavior?

Yes, you can do any kind of testing we can normally do, you just need know that you probably shouldn't modify the example to make it more testable. E.g. I wouldn't add a @visibleForTesting method to an example, or extra parameters to override things (like adding a Platform argument to override the current platform), since it complicates the example without a clear benefit to the reader.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating the first test as a golden image test is likely to ensure that all samples end up with such a test and the disadvantages of golden image testing are well known. Maybe we want to make the example test archetype check specific aspects of the LayoutBuilder example?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good point, I just wanted to show that we can do those. I modified this to test the layout behavior of the widgets.

@fluttergithubbot
fluttergithubbot merged commit 983cbb2 into flutter:master Oct 4, 2021
clocksmith pushed a commit to clocksmith/flutter that referenced this pull request Oct 29, 2021
@gspencergoog
gspencergoog deleted the add_example_test branch October 7, 2022 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c: contributor-productivity Team-specific productivity, code health, technical debt. d: examples Sample code and demos

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants