Magento 2如何通过命令行运行单元测试

在本教程中,我们将讨论如何通过命令行运行单元测试,命令行系列。如您所知,在Magento 2中,它们在中添加了许多命令bin/magento。这可能很难解决,让我解释一下如何通过命令行运行单元测试的更多细节。

如何通过命令行运行单元测试

转到Magento管理员根文件夹并显示用法:

php bin/magento dev:tests:run --help
Usage:                                                                                                                      
  dev:tests:run [options] [--] [<type>]                                                                                     
                                                                                                                            
Arguments:                                                                                                                  
  type                       Type of test to run. Available types: all, unit, integration, integration-all, static, static-a
ll, integrity, legacy, default [default: "default"]                                                                         
                                                                                                                            
Options:                                                                                                                    
  -c, --arguments=ARGUMENTS  Additional arguments for PHPUnit. Example: "-c'--filter=MyTest'" (no spaces) [default: ""]     
  -h, --help                 Display this help message                                                                      
  -q, --quiet                Do not output any message                                                                      
  -V, --version              Display this application version                                                               
      --ansi                 Force ANSI output                                                                              
      --no-ansi              Disable ANSI output                                                                            
  -n, --no-interaction       Do not ask any interactive question                                                            
  -v|vv|vvv, --verbose       Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug 

Help:                                                                                                                       
  Runs tests

运行单元测试的语法

php bin/magento dev:tests:run [options]

简单运行测试

php bin/magento dev:tests:run 

输出:

ERRORS!
Tests: 4163, Assertions: 14590, Errors: 6, Failures: 29, Warnings: 1, Skipped: 173, Incomplete: 1.
----------------------------------------------------------------------
FAILED - 4 of 5:
 - dev/tests/unit> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit
 - dev/tests/static/framework/tests/unit> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit
 - dev/tests/integration> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit
 - dev/tests/static> /usr/bin/php7.0 ./vendor/phpunit/phpunit/phpunit

相关文章

0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论