Skip to content
New issue

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

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

Already on GitHub? # to your account

Crdzbird/unit test flutter #259

Merged
merged 12 commits into from
Jul 30, 2021
10 changes: 10 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@
"--flavor",
"prod",
]
},
{
"name": "Widget Test",
"program": "test/",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--coverage"
]
}
]
}
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,43 @@ Once the required tools are installed and the lfs are downloaded, open the proje
- Edit the run config and add on the flavor option prod


## Unit Tests

To run the unit test you need to input the following setup.

Choose a reason for hiding this comment

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

Is there a way to do this from the command line?

Copy link
Author

Choose a reason for hiding this comment

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

yep. an example would be:

flutter run test/catcher_test.dart --coverage or
flutter run test/catcher_test.dart

Copy link
Author

Choose a reason for hiding this comment

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

if you wish to run everything just replace the catcher_test with an * and it should run everything

Choose a reason for hiding this comment

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

Thanks! Could you add that to the readme please?

Copy link
Author

Choose a reason for hiding this comment

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

Sure.

- Create a folder on the root of your project named: ```.vscode```
- Inside .vscode create a file named: ```launch.json```
- Add the following inside ```launch.json```
- The segment named `program` is to specificy if you wish to run all the U.T or a specific one.

```json
{
"version": "0.2.0",
"configurations": [
{
"name": "Widget Test",
"program": "test/",
"request": "launch",
"type": "dart",
"flutterMode": "debug",
"args": [
"--coverage"
]
}
]
}
```


<p>&nbsp;</p>

### Unit Test Graph

If you wanna visualize the current percentage of code coverage you need to do the following steps.

1. On your `terminal` check if you have installed: `lcov` if not then install.
2. Go to on your terminal `android-lantern/coverage` and type: `genhtml coverage/lcov.info -o coverage/html` that will generate a nice html file with the code coverage of all your files.
Copy link
Author

Choose a reason for hiding this comment

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

Explanation about how to generate a informative graph about the percentage of code coverage on the project.

#### NOTE: Please avoid to upload the generated files from coverage, this is because the numerous files that are created.

Choose a reason for hiding this comment

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

Can you please add the necessary directories/files to .gitignore?

Copy link
Author

Choose a reason for hiding this comment

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

Sure, im gonna omit the coverage and genhtml


### Extra

If you like that VSCode start running the project without the need of be constantly typing the command.
Expand Down
Loading