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

[testing_app] Add app functionality along with Widget Tests #476

Merged
merged 8 commits into from
Jun 16, 2020

Conversation

abd99
Copy link
Contributor

@abd99 abd99 commented Jun 14, 2020

I have added the app functionality and Widget Tests. Please let me know if anything else is needed here.

/cc @domesticmouse @RedBrogdon

void addRandomItems() {
for (var i = 0; i < 10; i += 2) {
favoritesList.add(Random().nextInt(50));
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This Screen is dependent on the Favorites Model for getting data. Since we are testing it directly, it was empty. So, I did something like this to add data into the model. Is this okay?

Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me


import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:testing_app/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
testWidgets('Smoke test', (tester) async {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As we are already testing all the screens separately, I'm wondering if this file has become unnecessary. What are your thoughts on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

If it doesn't add to the narrative, it gets cut.

On the flipside, demonstrating how to test individual widgets standalone outside of the screens they are embedded in sounds like a useful demo...

Copy link
Contributor

Choose a reason for hiding this comment

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

Either add a TODO or delete outright for the time being

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've deleted it for now. I think we can do it in the month of August. I've noted it down.

Copy link
Contributor

Choose a reason for hiding this comment

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

sgtm

- Widget Tests:
- To run on physical device or emulator:
- Navigate to the project's root folder using command line.
- Run `flutter run test/<file_path>`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you think it would be a good idea to have simple instructions on how to run different types of tests? Will add more in the future along with tests if we are keeping it.

Copy link
Contributor

Choose a reason for hiding this comment

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

We will probably need a mini tutorial here explaining how this sample demonstrates different styles of testing, and how to run each one. Something to do once we have all the testing styles in place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I'll add that to the list of things to be done once all of the testing styles are in place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe add a TODO here?

void addRandomItems() {
for (var i = 0; i < 10; i += 2) {
favoritesList.add(Random().nextInt(50));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good to me

- Widget Tests:
- To run on physical device or emulator:
- Navigate to the project's root folder using command line.
- Run `flutter run test/<file_path>`
Copy link
Contributor

Choose a reason for hiding this comment

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

We will probably need a mini tutorial here explaining how this sample demonstrates different styles of testing, and how to run each one. Something to do once we have all the testing styles in place.

home: HomePage(),
),
);
void main() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: add new line between createHomeScreen and main. I feel like this should have been picked up by flutter format...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wonder why it didn't. I even tried it again right now. Finally ended up adding it manually. I think flutter format doesn't add new lines on its own.

Copy link
Contributor

Choose a reason for hiding this comment

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

there is always something to add =)


import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:testing_app/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
testWidgets('Smoke test', (tester) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

If it doesn't add to the narrative, it gets cut.

On the flipside, demonstrating how to test individual widgets standalone outside of the screens they are embedded in sounds like a useful demo...

@domesticmouse domesticmouse removed the request for review from RedBrogdon June 16, 2020 04:05
@abd99
Copy link
Contributor Author

abd99 commented Jun 16, 2020

I've made the changes. You can go ahead and merge it when the build passes.

@domesticmouse domesticmouse merged commit 8fbc567 into flutter:testing_sample Jun 16, 2020
@domesticmouse
Copy link
Contributor

Landed, thanks @abd99

@abd99 abd99 deleted the testing_sample_abd branch June 18, 2020 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants