Skip to content

Conversation

@arowolojoshuao
Copy link
Contributor

Summary

Adds a Testing section to the README that addresses the Flutter testing cookbook recommendation to use http.Client instances instead of static methods for better testability.

Changes

  • Added Testing section after the composable client examples
  • Included dependency injection pattern example with DataService class
  • Added MockClient testing example with complete test case
  • Referenced Flutter testing cookbook for best practices

Related Issue

Fixes #389

Testing

  • Verified documentation formatting renders correctly
  • Ensured code examples are syntactically correct
  • Confirmed links to Flutter testing cookbook are valid

@github-actions
Copy link

github-actions bot commented Oct 28, 2025

PR Health

Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

Coverage ✔️
File Coverage

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

License Headers ✔️
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/http/example/main.dart

This check can be disabled by tagging the PR with skip-license-check.

Copy link
Collaborator

@brianquinlan brianquinlan left a comment

Choose a reason for hiding this comment

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

Awesome! Thank you for this!


## Testing

For better testability, especially in Flutter applications, it's recommended to use a [Client][] instance rather than the top-level functions like `http.get()` or `http.post()`. This approach makes it easier to mock HTTP requests in your tests.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you wrap the lines to 80 columns?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noted

```

> [!TIP]
> For more detailed testing guidance, see the
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe use more neutral language about mockito:

You can also use package:mockito to mock `http.Client.

For more detailed guidance, see the Flutter Testing Cookbook.


Some well-supported implementations are:

| Implementation | Supported Platforms | SDK | Caching | HTTP3/QUIC | Platform Native |
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you restore the original formatting? It's hard to read this in a narrow window.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay


> [!TIP]
> [The Flutter HTTP example application][flutterhttpexample] demonstrates
> [!TIP] > [The Flutter HTTP example application][flutterhttpexample] demonstrates
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please restore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay


> [!TIP]
> [The Flutter HTTP example application][flutterhttpexample] demonstrates
> [!TIP] > [The Flutter HTTP example application][flutterhttpexample] demonstrates
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please restore this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay

@arowolojoshuao
Copy link
Contributor Author

@brianquinlan, thank you for reviewing the PR. I have addressed your comments and pushed the updates.
Please take a look when you have a moment. Thanks

@arowolojoshuao
Copy link
Contributor Author

@brianquinlan, I have addressed the failing health check

Copy link
Collaborator

@brianquinlan brianquinlan left a comment

Choose a reason for hiding this comment

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

Thank you for writing this!

@brianquinlan brianquinlan merged commit 81b5979 into dart-lang:master Nov 3, 2025
34 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Documentation for testing

2 participants