PHPUnit : How to force an environment variable in Unit Test ?

In Magento 2 we all follow TDD approach and we often have a requirement to use the constants and global variables.

<Magento Directory>/dev/tests/unit/phpunit.xml

The element and its children can be used to configure PHP settings, constants, and global variables.

If you running individual Unit Case then you need to set the configuration path. I always run them from within PHPStorm. And there is an option to define the phpunit.xml path. Preferences > Languages & Frameworks > PHP > Test Frameworks

Configuring PHPUnit

Call the global variable in your setUp() function of the Unit Test.