-
-
Notifications
You must be signed in to change notification settings - Fork 24
Description
Describe the bug
The RobotCode plugin for PyCharm completely ignores the robot.toml
configuration when a test is launched using the gutter "play" icon (robot.toml
uses both the env
and listeners
settings simultaneously.
I have confirmed two critical facts:
- 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. - A separate, new minimal project with a very simple
robot.toml
(using only theargs
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
-
Create a project with the following file structure:
project-root/ ├── .env.test-env ├── EnvListener.py ├── robot.toml └── Tests/ └── login_test.robot
-
Add the following content to
.env.test-env
:# .env.test-env TEST_URL="http://test-url-from-dotenv-file.com"
-
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} ---")
-
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" = []
-
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
-
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