패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.5.0

test_coverage

Dart VM에서 테스트를 실행하고 커버리지 데이터를 수집하기 위한 명령줄 유틸리티입니다.

30일 다운로드
1.6천
좋아요
44
Pub 점수
30

패키지 설치

flutter pub add test_coverage

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

VM에서 Dart 테스트를 실행하고 커버리지 데이터를 수집하기 위한 명령줄 유틸리티입니다. 개발자가 테스트가 코드의 어느 정도를 커버하고 있는지 측정할 수 있도록 도와주며, 더 나은 테스트 품질과 미테스트된 코드 경로를 식별하는 데 도움을 줍니다. 이 도구는 CI/CD 파이프라인에 원활하게 통합되며, 단위 테스트와 통합 테스트 모두를 지원합니다. 다양한 형식으로 커버리지 보고서를 생성하여 분석 및 보고에 활용할 수 있습니다. 간단함과 효율성을 고려해 설계되어, 높은 테스트 커버리지 기준을 유지하려는 팀에게 특히 유용합니다.

사용 사례

  • CI/CD 워크플로에서 테스트 커버리지 측정
  • 테스트되지 않은 코드 영역 식별
  • 팀 리뷰를 위한 커버리지 보고서 생성
  • 자동화된 테스트 파이프라인과의 통합
  • 릴리스 전 테스트 완전성 검증
  • 시간에 따른 모니터링 커버리지 추세

주요 기능

  • Dart VM에서 테스트를 실행합니다
  • 세부적인 코드 커버리지 데이터를 수집합니다
  • 단위 및 통합 테스트를 지원합니다
  • 커버리지 보고서 생성
  • 간편한 CLI 통합
  • Flutter 및 Dart 프로젝트와 호환됩니다

적합한 대상

  • Dart 및 Flutter 개발자
  • 테스트 품질에 집중하는 팀
  • CI/CD 자동화 엔지니어
  • 카バレ지 준수를 요구하는 프로젝트
  • 개발자가 테스트 커버리지 향상 중
  • 품질 보증 팀

고려 사항

  • Dart SDK 설정이 필요합니다
  • 내장된 시각화 없음(외부 도구 필요)
  • 가상 머신 기반 테스트에 제한됨
  • 웹 또는 모바일 플랫폼에 대한 커버리지 데이터를 사용할 수 없습니다
  • 복잡한 프로젝트의 경우 추가 구성이 필요할 수 있습니다
  • 테스트 중에 핫 리로드를 지원하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

test_coverage Build Status Pub Coverage

A simple command-line tool to collect test coverage information from Dart VM tests. It is useful if you need to generate coverage reports locally during development.

Usage

Add dev dependency to your pubspec.yaml:

dev_dependencies:
  test_coverage: ^0.4.2

Run pub get to install. Then, in the root of your project run:

pub run test_coverage

Result is saved in coverage/lcov.info. If you have lcov tool installed on your system (for Mac it's brew install lcov) you can generate coverage reports using genhtml command:

genhtml -o coverage coverage/lcov.info
# Open in the default browser (mac):
open coverage/index.html

Integrations

Resulting coverage/lcov.info file is ready to be consumed by Codecov command-line tool, so no extra step is needed.

This library was not tested with coveralls yet.

Generating badge image

Coverage

Coverage badge SVG image is automatically generated and saved to coverage_badge.svg in your project root directory. You can add it to Git and use in README.md on Github as follows:

![Coverage](https://raw.githubusercontent.com/{you}/{repo}/master/coverage_badge.svg?sanitize=true)

If you don't need it you can pass --no-badge flag when running test coverage.

Known limitations

  • This library was created to run Dart VM tests. It has not been tested and likely won't work for Dart code targeting web platform (compiled to JavaScript). There is no need to use this tool for Flutter as it allows collecting coverage information with flutter test --coverage.

How it works

The tool performs following steps:

1. Generates test/.test_coverage.dart file (a "test all" script).

Scans your test/ directory to find all *_test.dart files and creates test/.test_coverage.dart which imports all found test files and runs corresponding main() of all tests functions within the same file (and process), which simplifies collection of coverage information.

It is recommended to add this file to your .gitignore.

Below is an example of test/.test_coverage.dart:

// Auto-generated by test_coverage. Do not edit by hand.
// Consider adding this file to your .gitignore.

import 'some_test.dart' as some_test;
import 'nested/other_test.dart' as other_test;
import 'some_other_test.dart' as some_other_test;

void main() {
  some_test.main();
  other_test.main();
  some_other_test.main();
}
2. Runs the tests

Following command is used to run the tests:

dart --pause-isolates-on-exit --enable_asserts --enable-vm-service \
  test/.test_coverage.dart
3. Collects and formats coverage information

When test execution is completed the tool uses functionality of the coverage package to collect and format coverage report.

Feel free to file feature requests and bug reports at the issue tracker.

4. Minimal coverage percentage

Set minimal coverage percentage to pass min-coverage percentage value of coverage.

5. See test output

print-test-output to show test output.

Show output of tests

Feel free to file feature requests and bug reports at the issue tracker.

카테고리

의존성

의존성 목록 5 개

소스 저장소

이 패키지를 사용하는 프로젝트