diff --git a/doc/tasks/codeception.md b/doc/tasks/codeception.md index 47f88dba..12555b6b 100644 --- a/doc/tasks/codeception.md +++ b/doc/tasks/codeception.md @@ -20,6 +20,8 @@ grumphp: fail_fast: false suite: ~ test: ~ + xml: false + html: false ``` @@ -47,3 +49,15 @@ When this option is specified it will only run tests for the given suite. If lef When this option is specified it will only run the given test. If left `null` Codeception will run all tests within the suite. This option can only be used in combination with a suite. + +**xml** + +*Default: false* + +When this option is enabled, Codeception will output an XML report for the test run. + +**html** + +*Default: false* + +When this option is enabled, Codeception will output an HTML report for the test run. diff --git a/src/Task/Codeception.php b/src/Task/Codeception.php index a03b4c9b..2a228959 100644 --- a/src/Task/Codeception.php +++ b/src/Task/Codeception.php @@ -26,13 +26,17 @@ public static function getConfigurableOptions(): ConfigOptionsResolver 'suite' => null, 'test' => null, 'fail_fast' => false, + 'xml' => false, + 'html' => false, ]); $resolver->addAllowedTypes('config_file', ['null', 'string']); $resolver->addAllowedTypes('suite', ['null', 'string']); $resolver->addAllowedTypes('test', ['null', 'string']); $resolver->addAllowedTypes('fail_fast', ['bool']); - + $resolver->addAllowedTypes('xml', ['bool']); + $resolver->addAllowedTypes('html', ['bool']); + return ConfigOptionsResolver::fromOptionsResolver($resolver); } @@ -60,6 +64,8 @@ public function run(ContextInterface $context): TaskResultInterface $arguments->add('run'); $arguments->addOptionalArgument('--config=%s', $config['config_file']); $arguments->addOptionalArgument('--fail-fast', $config['fail_fast']); + $arguments->addOptionalArgument('--xml', $config['xml']); + $arguments->addOptionalArgument('--html', $config['html']); $arguments->addOptionalArgument('%s', $config['suite']); $arguments->addOptionalArgument('%s', $config['test']); diff --git a/test/Unit/Task/CodeceptionTest.php b/test/Unit/Task/CodeceptionTest.php index 32d84dee..3adef1ab 100644 --- a/test/Unit/Task/CodeceptionTest.php +++ b/test/Unit/Task/CodeceptionTest.php @@ -29,6 +29,8 @@ public function provideConfigurableOptions(): iterable 'suite' => null, 'test' => null, 'fail_fast' => false, + 'xml' => false, + 'html' => false, ] ]; } @@ -143,5 +145,27 @@ public function provideExternalTaskRuns(): iterable 'test' ] ]; + yield 'xml' => [ + [ + 'xml' => true, + ], + $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), + 'codecept', + [ + 'run', + '--xml' + ] + ]; + yield 'html' => [ + [ + 'html' => true, + ], + $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), + 'codecept', + [ + 'run', + '--html' + ] + ]; } }