nauni-limited / test-suite-bundle
提供基于属性过滤的通用自动化测试套件
dev-master
2022-01-13 00:52 UTC
Requires
- php: >=8.0
Requires (Dev)
- behat/behat: ^3.8
- infection/infection: ^0.21
- johnkary/phpunit-speedtrap: ^4.0-dev
- phpstan/phpstan: ^0.12
- phpstan/phpstan-doctrine: ^0.12.33
- phpstan/phpstan-mockery: ^0.12.13
- phpstan/phpstan-phpunit: ^0.12.18
- phpstan/phpstan-symfony: ^0.12.21
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.5
- symfony/config: ^5.2
- symfony/console: ^5.2
- symfony/dependency-injection: ^5.2
- symfony/finder: ^5.2
- symfony/serializer: ^5.2
This package is not auto-updated.
Last update: 2024-09-20 12:06:29 UTC
README
项目目标
旨在提供单个命令来运行整个代码库上的常见测试工具,在包含给定套件属性的指定文件上运行(额外目标:或在内置的 git diff 套件 git-diff
上)。
项目中的代码示例
<?php namespace App\Controller; use Symfony\Component\Routing\Annotation\Route; use Symfony\Component\HttpFoundation\JsonResponse; use Nauni\Bundle\NauniTestSuiteBundle\Attribute\Suite; #[Suite(['controller', 'lucky'])] class LuckyController { #[Route('/lucky/number', name: 'luck_number', methods: ['GET', 'HEAD'])] public function number(): JsonResponse { $number = random_int(0, 100); return new JsonResponse( ['number' => $number] ); } }
命令
console test:all --suite [suite]
命令,您可以指定一个套件进行过滤,或运行所有测试
console test:feature --suite [suite]
命令,可以运行功能测试(behat)
console test:unit --suite [suite]
命令来运行单元测试,这将包括感染测试
console test:coding-standards --suite [suite]
命令来运行编码标准(phpcs)
console test:code-quality --suite [suite]
命令来运行 phpmd 和 phpstan
配置
将暴露某些自定义设置作为 symfony yml 文件,但所有命令都将使用/操作原始工具配置配置。
示例
- 对于 PHP 单元测试,我们将向项目的 phpunit.xml 中添加一个 testsuite 节点,其中包含指定测试套件中的文件列表。
单个工具的配置
- 您需要根据项目需求配置单个工具。
- 我们为每个工具提供了一些基本的示例配置,这些是存储在包根目录中的
.dist
文件,您可以将其复制到项目根目录并删除.dist
扩展名。这样,您可以使用我们的默认规则集开始测试。