Skip to content

Commit

Permalink
Merge pull request #1107 from petrisorciprian-vitals/patch-1
Browse files Browse the repository at this point in the history
Add codeception XML/HTML reporting support to grumphp
  • Loading branch information
veewee committed Sep 14, 2023
2 parents affbb6c + 92b66b9 commit fb70da3
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
14 changes: 14 additions & 0 deletions doc/tasks/codeception.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ grumphp:
fail_fast: false
suite: ~
test: ~
xml: false
html: false
```


Expand Down Expand Up @@ -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.
8 changes: 7 additions & 1 deletion src/Task/Codeception.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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']);

Expand Down
24 changes: 24 additions & 0 deletions test/Unit/Task/CodeceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function provideConfigurableOptions(): iterable
'suite' => null,
'test' => null,
'fail_fast' => false,
'xml' => false,
'html' => false,
]
];
}
Expand Down Expand Up @@ -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'
]
];
}
}

0 comments on commit fb70da3

Please sign in to comment.