Skip to content

ci(dart): add unit tests and end-to-end sample execution to quickstart workflow - #9313

Merged
Vincent Biret (baywet) merged 9 commits into
microsoft:mainfrom
hardikkaurani:fix/dart-quickstart-e2e-and-test-suite
Nov 10, 2026
Merged

Vincent Biret (baywet) merged 9 commits into
microsoft:mainfrom
hardikkaurani:fix/dart-quickstart-e2e-and-test-suite

Conversation

@hardikkaurani

Copy link
Copy Markdown
Contributor

Summary

In get-started/quickstart/dart, the continuous integration workflow (.github/workflows/get-started-dart.yml) previously only analyzed source files and compiled bin/cli.dart into an executable without running any test assertions or validating end-to-end client execution. Additionally, test/cli_test.dart contained only a template stub, leaving client initialization, request information generation, query parameter mapping, and model serialization untested. Finally, bin/cli.dart was missing a deletion completion log, unlike other language quickstarts.

This pull request completes the Dart quickstart test coverage and aligns its CI pipeline with other languages in kiota-samples (such as Python, PHP, TypeScript, and Go).

Changes

  1. Parity in Quickstart CLI:

    • Added print('Deleted post'); in get-started/quickstart/dart/bin/cli.dart following the DELETE request.
  2. Standard Build Artifact Ignore:

    • Updated get-started/quickstart/dart/.gitignore to ignore .packages, build/, and bin/*.exe.
  3. Comprehensive Dart Quickstart Unit Tests:

    • Updated get-started/quickstart/dart/test/cli_test.dart to verify:
      • PostsClient initialization with AnonymousAuthenticationProvider and DefaultRequestAdapter, including base URL validation (https://jsonplaceholder.typicode.com).
      • Request information building for GET posts, including Accept: application/json headers and URL template formatting.
      • Query parameter mapping for userId and title filtering.
      • Payload serialization for POST requests.
      • Path parameter formatting (post%2Did) for single-item GET and DELETE operations.
      • Post model properties and field deserializer registrations.
  4. CI Workflow Verification:

    • Added a Run tests step (dart test) in .github/workflows/get-started-dart.yml.
    • Added a Run quickstart sample step (dart run ./bin/cli.dart) in .github/workflows/get-started-dart.yml to verify end-to-end live API execution against JSONPlaceholder.

Verification

  • dart analyze --fatal-infos: 0 issues found.
  • dart test: 7/7 unit tests passed.
  • dart compile exe ./bin/cli.dart: Succeeded.
  • dart run ./bin/cli.dart: Successfully executed all CRUD operations against JSONPlaceholder.

Add a printed confirmation message upon successful completion of the
DELETE request in the Dart quickstart CLI application, aligning output
behavior with other Kiota language quickstart samples.

Signed-off-by: Hardik Kaurani <[email protected]>
Ignore conventional Dart build and compilation artifacts (.packages,
build/, and bin/*.exe) to ensure clean working copies during local
analysis and compilation.

Signed-off-by: Hardik Kaurani <[email protected]>
… quickstart tests

Add unit tests verifying that PostsClient properly initializes with
DefaultRequestAdapter and configures the default base URL against
JSONPlaceholder.

Signed-off-by: Hardik Kaurani <[email protected]>
… posts

Add unit tests asserting that PostsRequestBuilder generates accurate
RequestInformation for GET operations, sets the application/json Accept
header, and maps configured query parameters (userId and title).

Signed-off-by: Hardik Kaurani <[email protected]>
…operations

Add unit tests asserting that toPostRequestInformation serializes the
request payload and that byPostId correctly formats path parameters for
individual item GET and DELETE operations.

Signed-off-by: Hardik Kaurani <[email protected]>
Add unit tests verifying Post model field getters and setters as well as
registration of property parsers within getFieldDeserializers.

Signed-off-by: Hardik Kaurani <[email protected]>
Add a 'Run tests' step invoking 'dart test' in the build-quickstart-dart
job so that unit tests in get-started/quickstart/dart/test are verified
during continuous integration.

Signed-off-by: Hardik Kaurani <[email protected]>
…rkflow

Add a 'Run quickstart sample' step executing 'dart run ./bin/cli.dart' in
the build-quickstart-dart job to verify end-to-end client execution and
live request/response serialization against JSONPlaceholder in CI.

Signed-off-by: Hardik Kaurani <[email protected]>
@hardikkaurani
Hardik K (hardikkaurani) requested a review from a team as a code owner November 5, 2026 19:13
Copilot AI balanced review requested due to automatic review settings November 5, 2026 19:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@hardikkaurani

Hardik K (hardikkaurani) commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet),

While reviewing the quickstart samples across languages, I noticed that the Dart quickstart workflow (get-started-dart.yml) only performed static analysis and compilation, without running tests or verifying end-to-end client execution against the mock API, unlike the Python, PHP, TypeScript, and Go workflows.

Additionally, test/cli_test.dart contained an empty template stub, and bin/cli.dart was missing the completion log after deletion.

This PR adds:

  1. Unit tests: Added tests in test/cli_test.dart covering PostsClient initialization, request information generation, query parameter mapping, payload serialization, and Post model deserializers.
  2. CI workflow improvements: Added dart test and live dart run ./bin/cli.dart sample execution steps to the GitHub Actions workflow.
  3. Build and sample cleanup: Added clean build artifact exclusions to .gitignore and restored the matching completion output in bin/cli.dart.

All checks and tests pass locally:

  • dart analyze --fatal-infos
  • dart test
  • dart run ./bin/cli.dart

Whenever you have a moment, I'd appreciate your review. Thank you!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the Dart quickstart test and CI updates.

No open issues 🎉

Review effort: Balanced

@baywet
Vincent Biret (baywet) requested a balanced review from Copilot November 9, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment thread .github/workflows/get-started-dart.yml Outdated
working-directory: get-started/quickstart/dart

- name: Run quickstart sample
run: dart run ./bin/cli.dart

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.

Addressed in b1ed447. Removed the live HTTP sample execution step from get-started-dart.yml to prevent flakiness from external network dependencies and rate limits, relying on the deterministic unit test suite instead.

Comment on lines +2 to +3
import '../client/models/post.dart';
import '../client/posts_client.dart';

@hardikkaurani Hardik K (hardikkaurani) Nov 9, 2026 •

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.

In this sample, the client is generated directly at the quickstart root under get-started/quickstart/dart/client/, outside lib/, alongside bin/ and test/, following the standard Kiota quickstart layout. Since it resides outside lib/, Dart's package: scheme cannot resolve it directly, so relative imports from sibling directories are consistent with the existing pattern in bin/cli.dart.

Also removed the unused template stub and package:cli import in b1ed44759.

Comment on lines +63 to +67
expect(getInfo.pathParameters['post%2Did'], 5);

var deleteInfo = itemReq.toDeleteRequestInformation();
expect(deleteInfo.httpMethod, HttpMethod.delete);
expect(deleteInfo.pathParameters['post%2Did'], 5);

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.

Addressed in b1ed447. Decoupled path parameter assertions from the internal URL-encoded key name by checking that pathParameters.values contains 5 for both GET and DELETE request information.

Comment on lines +16 to +17
var authProvider = AnonymousAuthenticationProvider();
var requestAdapter = DefaultRequestAdapter(authProvider: authProvider);

@hardikkaurani Hardik K (hardikkaurani) Nov 9, 2026 •

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.

Addressed in b1ed44759. Replaced var with final for all local variables that are not reassigned across setUp and all test cases.

…remove live ci call

- Remove live HTTP run step in get-started-dart.yml to prevent CI flakiness from external services.

- Assert path parameter presence via values rather than URL-encoded parameter key.

- Use final for immutable local variables in test setup and test cases.

- Remove unused default template calculate test and package import.

Signed-off-by: Hardik Kaurani <[email protected]>
@hardikkaurani

Hardik K (hardikkaurani) commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi Vincent Biret (@baywet), pushed an update addressing the review feedback:

  • CI determinism: Removed the live HTTP sample execution step from get-started-dart.yml to avoid potential flakiness caused by external network latency and rate limits. CI now relies on deterministic unit tests and compilation.
  • Path parameter assertions: Decoupled byPostId assertions from internal parameter key encoding (post%2Did) by checking value presence through pathParameters.values.
  • Immutability and code style: Replaced var with final for all immutable local variables across setUp and test cases in cli_test.dart.
  • Cleanup: Removed the unused template calculate stub and package:cli import.

All unit tests (dart test), static analysis (dart analyze --fatal-infos), and compilation checks pass cleanly. Ready for another look!

@baywet
Vincent Biret (baywet) merged commit b46c269 into microsoft:main Nov 10, 2026
29 checks passed
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.

3 participants