Skip to content

[BUG] PyCharm Plugin Ignores robot.toml Configuration #483

@brunoAmado

Description

@brunoAmado

Describe the bug

The RobotCode plugin for PyCharm completely ignores the robot.toml configuration when a test is launched using the gutter "play" icon (▶️). This failure occurs in my primary development project, specifically when a profile in robot.toml uses both the env and listeners settings simultaneously.

I have confirmed two critical facts:

  1. Running the exact same setup from the integrated terminal works perfectly. This proves the Python environment, listener script, .env files, and Robot Framework itself are all correctly configured.
  2. A separate, new minimal project with a very simple robot.toml (using only the args setting) also works perfectly.

This indicates that the bug is not a general failure, but a specific issue that arises when the project or robot.toml configuration reaches a certain complexity, preventing the plugin from applying the settings from the active profile.

Steps To Reproduce

  1. Create a project with the following file structure:

    project-root/
    ├── .env.test-env
    ├── EnvListener.py
    ├── robot.toml
    └── Tests/
        └── login_test.robot
    
  2. Add the following content to .env.test-env:

    # .env.test-env
    TEST_URL="http://test-url-from-dotenv-file.com"
  3. Add the following Python code to EnvListener.py:

    # EnvListener.py
    import os
    from dotenv import load_dotenv
    
    class EnvListener:
        ROBOT_LISTENER_API_VERSION = 3
    
        def __init__(self):
            target = os.getenv('DEFAULT_ENVIRONMENT', 'test-env')
            env_filename = f".env.{target}"
            env_path = os.path.join(os.path.dirname(__file__), env_filename)
    
            if os.path.exists(env_path):
                print(f"--- EnvListener: Loading environment from: {env_path} ---")
                load_dotenv(dotenv_path=env_path)
            else:
                print(f"--- EnvListener WARNING: Environment file not found: {env_path} ---")
  4. Add the following configuration to robot.toml:

    # robot.toml
    defaultProfile = "test-env"
    
    [profiles.test-env]
    description = "Runs tests against the test.env environment."
    env = { DEFAULT_ENVIRONMENT = "test-env" }
    
    [profiles.test-env.listeners]
    "EnvListener.py" = []
  5. Add the following test case to Tests/login_test.robot:

    *** Test Cases ***
    Test If Env Var Was Loaded
        Log To Console    URL is: %{TEST_URL=FAILED_TO_LOAD}
        Should Not Be Equal    %{TEST_URL}    FAILED_TO_LOAD
  6. In the PyCharm editor, open login_test.robot and click the gutter "play" icon (▶️) next to the test case.

Expected behavior
The test execution console should show the message --- EnvListener: Loading environment from: ... ---. The test should pass, and the Robot Framework log should show that the %{TEST_URL} variable had the value http://test-url-from-dotenv-file.com.

Actual Result
The --- EnvListener... message does not appear in the console. The test fails with the message FAILED_TO_LOAD' == 'FAILED_TO_LOAD'. This proves that the listeners configuration was ignored, the EnvListener.py script was never executed, and the environment variable was not loaded.

Screenshots/ Videos
(Not applicable, but can be provided if necessary.)

Logs
(Instructions for user: Please open the "Output" panel in PyCharm, select "RobotCode Language Server" from the dropdown, and paste any relevant error or warning messages here.)

Additional context
This bug report is the result of extensive troubleshooting. The key takeaway is that the listener-based setup shown above works perfectly when executed from the command line inside the PyCharm terminal:
$env:DEFAULT_ENVIRONMENT="test-env"; robot --listener EnvListener.py Tests/

This confirms the issue is isolated to the plugin's UI launcher not correctly parsing or applying the robot.toml configuration in this specific scenario.

Desktop :

  • IDE: PyCharm 2025.1.3.1 (Community Edition)
  • RobotCode Version: 1.7.0
  • OS: Windows 11
  • Python Version: 3.12
  • RobotFramework Version: 7.3.2
  • Additional tools: python-dotenv

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions