8000 Include installed Test Frameworks in TestFrameworkTypes - Fixes 1863 by thompsnm · Pull Request #1871 · infection/infection · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Include installed Test Frameworks in TestFrameworkTypes - Fixes 1863 #1871

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 25, 2023

Conversation

thompsnm
Copy link
Contributor

This PR:

Fixes #1863

Per the issue description:

My team has implemented a binary that wraps around PHPUnit and configures / executes tests for us when we simply point it at a particular directory. I want to implement an Infection Test Framework extension that we would only use internally that executes tests via our binary. Unfortunately, that's not possible because specifying a Test Framework whose type is not hardcoded in TestFrameworkTypes causes Infection to throw an error.

Changes mage:

I replaced all references to the constant array TestFrameworkTypes::TYPES with a static function TestFrameworkTypes::getTypes() that parses GeneratedExtensionsConfig::EXTENSIONS to include the names of all installed Adapters.

): array {
$types = self::$defaultTypes;

if (count($installedExtensions) > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see there's a warning from "GitHub Actions / Mutation Testing Code Review Annotations 8.1" on this line that changing > to >= is an escaped Mutant. I just confirmed that this case would be caught by phpstan analyse:

 ------ ---------------------------------------------------------------------
  Line   TestFramework/TestFrameworkTypes.php
 ------ ---------------------------------------------------------------------
  74     Comparison operation ">=" between int<0, max> and 0 is always true.
 ------ ---------------------------------------------------------------------

Assert::classExists($factory);

if (!is_a($factory, TestFrameworkAdapterFactory::class, true)) {
continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we throw here instead, telling user they made a mistake?

Copy link
Member
@sanmai sanmai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a good idea.

Copy link
Member
@maks-rafalko maks-rafalko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @thompsnm

@maks-rafalko maks-rafalko merged commit 3e0387b into infection:master Jun 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infection can't run custom Test Framework extensions because TestFrameworkTypes is hardcoded
3 participants
0