# libcoverage **Repository Path**: dvaknheo/libcoverage ## Basic Information - **Project Name**: libcoverage - **Description**: 快速创建覆盖你自己 PHP 库的测试代码 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 0 - **Created**: 2021-01-08 - **Last Updated**: 2022-04-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # LibCoverage [English](README.md) | [中文](README-zh-CN.md) *** v1.0.1 *** LibCoverage for full code coverage for php library creater. ## usage ``` composer require --dev dvaknheo/libcoverage composer exec libcoverage # show help composer exec libcoverage setup phpunit cat test_reports/index.html # you can use browser open it # composer exec libcoverage cloze # write a new class , cloze it. # phpunit tests/AppTest.php && phpunit tests/support.php # report for a class change # composer exec libcoverage report # ``` `composer exec libcoverage setup ` create `phpunit.xml` and `tests/boostrap.php` and `tests/support.php` on not exists run `phpunit` , browse `test_reports/index.html` `setup` command folow `src` create `tests/*Test.php` test template. e.g. src/App.php ```php foo(); //*/ LibCoverage::End(); } } ``` finish test code, good job. next image is LibCoverage self unit test report ![capture](docs/capture.png) ## LibCoverage options ``` public $options = [ 'namespace' => null, 'path' => null, 'path_src' => 'src', 'path_dump' => 'test_coveragedumps', 'path_report' => 'test_reports', 'path_test' => 'tests', 'path_data' => 'tests/data_for_tests', 'auto_detect_namespace' => true, 'override_class' => null, ]; ``` `composer exec libcoverage` can take these options on. e.g. `vendor/bin/libcoverage --path='abc' --path_test=test` ## LibCoverage class public methods static methods ``` LibCoverage::G($object=null); // changable singleton. LibCoverage::Begin($class); // begin a class trace. LibCoverage::End(); // end a class trace. ``` ext methods ``` LibCoverage::G()->init(array $options, ?object $context = null); // boostrap.php use to init LibCoverage::G()->showAllReport(); // support.php use to report LibCoverage::G()->createProject(); // use by command setup LibCoverage::G()->createTests(); // use by command cloze ``` other methods ``` LibCoverage::G()->isInited(); LibCoverage::G()->addExtFile($extFile); // use to global function and more. LibCoverage::G()->getClassTestPath($class); // directory for class . e.g. tests/data_for_test/<$class> LibCoverage::G()->cleanDirectory($dir); // for clean support dir. ``` ## customer and option 'override_class' ```php