add-missing-unit-test

bởi flutter

Thêm một bài kiểm thử đơn vị mới cho một lớp hiện chưa có bài kiểm thử nào hoặc thêm một trường hợp kiểm thử mới vào tệp kiểm thử hiện có, xác minh sự cải thiện bằng Kover.

npx skills add https://github.com/flutter/flutter-intellij --skill add-missing-unit-test

Skill: Add Missing Unit Test

You are tasked with adding a new unit test for a class that currently lacks one, or adding a new test case to an existing test file, to improve code coverage and reliability.

Objective

Add a new unit test for a class that currently lacks one, or add a new test case to an existing test file, to improve code coverage and reliability.

Workflow Instructions

1. Identify Target

  • Choose a class in src/ that has complex logic but logic coverage is missing or incomplete.

2. Establish Baseline

  • Run ./gradlew testClasses to compile all sources (production and test) and ensure the project is in a valid state.
  • Run ./gradlew verifyPlugin to ensure no plugin verification issues exist.
  • Run ./gradlew test (or specific test if it exists) to establish current pass/fail status.
  • Run tests with Kover (./gradlew koverHtmlReport or ./gradlew koverXmlReport) to determine current coverage percentage for target class.

3. Implement Test

  • Create a new test class ([ClassName]Test) in testSrc/ if it doesn't exist.
  • Add test cases to cover specific methods, edge cases, and branches.
  • Ensure the test follows project testing conventions (naming, mocking, assertions).

4. Verify

  • Run ./gradlew testClasses to ensure new test compiles.
  • Run new test (and related tests) to ensure it passes.
  • Run ./gradlew verifyPlugin to ensure no regressions in plugin verification.
  • Run Kover again to confirm coverage improvement.

5. Report & Review

  • Summarize test added and coverage improvement.
  • Test Location: Explicitly state where in the IDE user should go to test changed functionality (e.g., "Run the new test file [TestFileName]").
  • Action: Ask user to review new test closely. Validate that code being tested is actively used (e.g., check that it is not dead code/0 references).
  • Do not commit or push.
  • Provide a suggested Git commit message, explicitly including the Kover coverage improvement:
    • Example Pattern: Add unit tests for [Class Name]. Coverage verified using Kover. Coverage improvement: [Class Name]: ~[X]% line coverage ([Y] covered, [Z] uncovered).

Thêm skills từ flutter

dart-modern-features
flutter
Để tìm các ứng viên cho việc hiện đại hóa:
flutter-fix-layout-issues
flutter
Sửa lỗi bố cục Flutter (tràn, ràng buộc vô hạn) bằng các công cụ Dart và Flutter MCP. Sử dụng khi xử lý "RenderFlex overflowed", "Vertical…
adding-release-notes
flutter
Thêm mô tả thay đổi dành cho người dùng vào ghi chú phát hành DevTools. Sử dụng khi ghi lại các cải tiến, sửa lỗi hoặc tính năng mới trong tệp NEXT_RELEASE_NOTES.md.
reviewing-devtools-prs
flutter
Quy trình rà soát pull request riêng cho kho lưu trữ DevTools, áp dụng các nguyên tắc về phong cách và mẫu rà soát phổ biến của DevTools. Sử dụng khi rà soát pull request trong…
dart-use-primary-constructors
flutter
Giúp người dùng viết các primary constructor đúng cú pháp và ngữ nghĩa trong Dart, đồng thời di chuyển/sử dụng cú pháp constructor mới, cú pháp dấu chấm phẩy thân rỗng,…
code-documentation
flutter
Hướng dẫn viết tài liệu mã hiệu quả, bao gồm docstrings, JSDoc, dartdoc và các chú thích triển khai. Sử dụng kỹ năng này khi viết mã mới, thêm…
api-review
flutter
Xem xét mã được chỉ định theo các nguyên tắc thiết kế API chuẩn. Sử dụng kỹ năng này khi người dùng yêu cầu đánh giá API hoặc kiểm tra mã theo thiết kế API…
flutter-accessibility
flutter
Triển khai các tiêu chuẩn truy cập WCAG 2 và EN 301 549 cùng bố cục thích ứng trong ứng dụng Flutter. Áp dụng chú thích ngữ nghĩa, kích thước vùng chạm (tối thiểu 48x48 dp) và tỷ lệ tương phản văn bản (4.5:1 cho văn bản nhỏ, 3:1 cho văn bản lớn) trên các nền tảng di động, web và máy tính để bàn. Cung cấp logic quyết định cho khởi tạo ngữ nghĩa web, bao bọc widget tương tác, chuyển đổi bố cục dựa trên kích thước màn hình và xử lý đầu vào bàn phím/chuột. Bao gồm quản lý điều hướng tiêu điểm qua FocusTraversal