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

Feature Request: Ability to Set Environment Variables During Test Execution #204

Open
KentarouTakeda opened this issue Nov 17, 2024 · 0 comments

Comments

@KentarouTakeda
Copy link

Hello Tsai,

Thank you for creating such a useful tool. I've been using it for a few days, and it has definitely improved my developer experience.

I would like to request the addition of a feature that allows setting arbitrary environment variables during test execution.

I'm confident that this feature would make the tool even more convenient in several use cases.

Using Xdebug

Enabling Xdebug significantly slows down execution, so I prefer to disable it by default:

[xdebug]
xdebug.mode = off
xdebug.start_with_request = yes

and only enable it via environment variables when needed:

$ XDEBUG_MODE=debug phpunit

Utilizing Framework Features

Many frameworks have features that allow controlling behavior through environment variables. For example, in Laravel, we can switch the configuration files loaded by setting APP_ENV.

For instance, running phpunit from the command line is intended for CI environments, whereas executing it from a GUI tool allows us to run each test individually. Such switching can make testing more efficient:

$ APP_ENV=phpunit-for-vs-code phpunit

Feature Request

It seems that these functionalities are not currently available in PHPUnit for VSCode.

  • When I added the above settings to phpunit.php or phpunit.phpunit, the tests failed to start. It appears that the entire string is recognized as the execution command.
  • Adding -d xdebug.mode=debug to phpunit.args did not work either. It seems that the environment variables need to be set before the PHP command is executed.

I would appreciate your consideration.

Sincerely,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants