Create the launch.json file

Description

This file is a a VS Code workspace configuration file, which is used to configure how the editor (Visual Studio Code) behaves for a specific project (customization).

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Run XTR",
            "type": "debugpy",
            "request": "launch",
            "program": "C:\\Users\\user.name\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages\\xtr\\cli\\__init__.py",
            "args": [
                "--output_path",
                "C:\\Users\\user.name\\path\\to\\Results",
                "core",
                "-c",
                "C:\\Users\\user.name\\path\\to\\Config\\Test_bench_config\\Test_bench_name\\Test_bench_config.yaml",
                "--database",
                "C:\\Users\\user.name\\path\\to\\Config\\Databases\\database_name.db",
                "run",
                "--test_series",
                "C:\\Users\\user.name\\path\\to\\Config\\TestSeries\\Test_series_name.xml",
                "--search_paths",
                "C:\\Users\\user.name\\path\\to\\Tests"
            ],
            "console": "integratedTerminal",
            "justMyCode": true,
            "env": {
                "PYTHONPATH": "C:\\Users\\user.name\\AppData\\Local\\Programs\\Python\\Python311"
            }
        }
    ]
}
  • version: This field specifies the version of the configuration format. It is used for compatibility checks, meaning it helps ensure that the configuration file is understood by the IDE (VS Code) and the debugger (debugpy).

  • configurations: This is an array that can contain one or more configuration objects.

    • name: A human-readable name for the configuration, which helps in identifying which debug configuration to use (for easy reference). In this case, it is used for running XTR.

    • type: The type of the debugger to use. In this case, it is set to ‘debugpy‘, the Python extension for debugging.

    • request: The type of request to send to the debugger. ‘launch’ means that the configuration is used to start a new debugging session.

    • program: The path to the main Python script or module to be executed. In this case, the __init__.py pf the XTR CLI. It serves as the entry point of the XTR program.

    • args: The list of command-line arguments passed to the program. They are essential for configuring how the program should run and what resources it should use:

      • –output_path: The path to the directory where the output will be saved. In this case, it refers to the Results directory.

      • core: A command within XTR to provide necessary files for the MTF framework if used.

        • -c: The path to the test bench configuration file.

        • –database: The path to the database file.

      • run: A command to start the main execution.

        • –test_series: The path to an XML file defining test series to execute.

        • –search_paths: Additional directories where the Python interpreter should look for modules.

    • console: The type of console to use for output. ‘integratedTerminal‘ means that the output will be shown in the integrated terminal within the IDE.

    • justMyCode: Controls whether the debugger should step into code in external modules or libraries. When set to true, this option ensures that only the user’s code is debugged.

    • env: A dictionary of environment variable configuration. Here, PYTHONPATH is set to the path where Python is installed on the User’s machine. This ensures that the debugger runs in the correct environment with the appropriate Python interpreter and libraries.

Important

In the example above, we used Python 3.11; however, XTR supports both 3.10 and 3.11.

Place in the Project Directory

Make sure to create the launch.json file at the following standard location: Project_directory/.vscode/launch.json.

The .vscode is a hidden directory that contains configuration files for Visual Studio Code (VS Code), a popular code editor.

Project_directory
 |
 |-- .vscode
 |   |-- launch.json <===============================