The Portable Environment File

A portable environment file is a text-based configuration file that is utilized by the Micro Focus Unit Testing Framework to provide environment variables specified in a test case.

You can use the same portable environment file for a test case compiled in a number of different ways, and run on a number of different platforms. By settings different values for a variable within the sections detailed in the table below, the Micro Focus Unit Testing Framework will determine the appropriate value for the test. As well as the global section, one section from each of the platform, compilation, bitism, and threading sections is active for any one test run.

When coding a protable environment file, you may omit sections that you do not require, and included sections can be coded in any order. Where multiple sections are in effect that contain the same variable, the value is taken from the last section specified.

To ensure that the file is used when you run the tests, save it with the same base name as the base name of your test suite (i.e. the base name of your .dll, .int, .gnt, .so, or .mfu file), and with an extension of .mfuenv, and then place it in the same location as your test suite.

Section name Purpose
[global] Section used for all tests irrespective of platform, bitism, etc...
[windows] Section used depending on operating system flag.
[unix]
[jvmgen] Section used when the test is compiled to JVM COBOL.
[dotnet] Section used when the test is compiled to .NET COBOL.
[dotnet_core] Section used when the test is compiled to .NET COBOL and you are using .NET Core.
[native] Section used when the test is compiled to any of: int, gnt, obj, dll, exe, or so.
[64bit] Section used depending on the bitism used during compilation.
[32bit]
[threaded] Section used when the threaded Run-Time System is in effect.
[non-threaded] Section used when the non-threaded Run-Time System is in effect.
Tip: To re-use a variable that has been defined in another section, reference it using the $env_name or ${env_name} notation; for example:
[windows]
CSV_BASEDIR=C:\tests\
[unix]
CSV_BASEDIR=/home/tests/
[global]
CSV_DATADIR=${CSV_BASEDIR}data
CSV_DATADIR resolves to C:\tests\data on Windows and /home/tests/data on UNIX. Using the bracketed notation also enables standard bash modification, where a default value is used if the variable is not already defined: ${CSV_BASEDIR:-alt_data}
CAUTION:
Using hard-coded path names in your .mfuenv file could make it less-portable, especially when using it as part of a source control or CI/CD process.

Example:

The following excerpt is from a data-driven test that is utilizing a variable (CSVDIR) in code:
...
ENTRY "MFUM_DOBQUOTE".
   move "csv:$CSVDIR/dobquote.csv" to MFU-MD-TESTDATA
   goback.
...

The following portable environment file resolves the CSVDIR variable to data_win_64 when compiled to 64-bit on Windows; data_win when compiled to 32-bit on Windows; data_64 when compiled to 64-bit on Linux; and data when compiled to 32-bit on Linux. (The building of the path is cumulative as it works through the file.)

[global]
filepath=data 

[windows]
filepath=${filepath}_win 

[64bit]
filepath=${filepath}_64