Skip to content
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

Allow reusing surefire environmentVariables for pitest #1317

Open
MosheElisha opened this issue Mar 21, 2024 · 3 comments
Open

Allow reusing surefire environmentVariables for pitest #1317

MosheElisha opened this issue Mar 21, 2024 · 3 comments

Comments

@MosheElisha
Copy link

Hi,

My code requires quite a lot of environment variables to run properly.
They are configured in the maven-surefire-plugin > configuration > environmentVariables so the unit tests will pass.

The code (and tests) will fail without these environmentVariables (it actually took me a long time to understand that this is the reason why I don't see mutation coverage).

Currently, I need to repeat the environmentVariables I defined in maven-surefire-plugin configuration also in pitest-maven configuration.

Would be great if there can be a way to use the surefire environmentVariables for pitest-maven so they will be defined only once.
Something like mergeSurefireEnvironmentVariables=true.

Current workaround is to place the env var value in a property so at least the value can be shared.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>${maven.surefire.plugin.version}</version>
    <configuration>
        <environmentVariables>
            <ONE_OF_MANY>value</ONE_OF_MANY>
            ...
        </environmentVariables>
    </configuration>
</plugin>
<plugin>
    <artifactId>pitest-maven</artifactId>
    <groupId>org.pitest</groupId>
    <version>${pitest-maven.version}</version>
    <configuration>
        ...
        <environmentVariables>
            <ONE_OF_MANY>value</ONE_OF_MANY>
            ...
        </environmentVariables>
    </configuration>
</plugin>
@hcoles
Copy link
Owner

hcoles commented Mar 28, 2024

Hi @MosheElisha,

Thanks for the suggestion. This ought to be straight forward, I'll look to include it in the next release.

@hcoles
Copy link
Owner

hcoles commented Mar 28, 2024

This in now implemented in #1319. The behavior is always on, which I shouldn't imagine would cause an issue. If different values are needed when running via pitest, the ones from surefire can be overwritten in the pitest config.

@MosheElisha
Copy link
Author

Wow! Perfect! Thanks a lot, @hcoles !

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

No branches or pull requests

2 participants