youneselbarnoussi / vscode-bdd-python-test-adapter Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
Hi,
The new Text Explorer UI update (2.20.2) is impacting Behave Test Explorer on VSCode. In this version the extension is not working properly.
Best regards,
I'm gettign the following errors. What am i doing wrong?
2023-10-18 09:31:55.442 [info] > "C:\Program Files\Python310\python.exe" -m pytest -p vscode_pytest --collect-only features
2023-10-18 09:31:55.443 [info] cwd: ./features
2023-10-18 09:31:56.325 [info] Test server connected to a client.
2023-10-18 09:31:56.329 [info] ResultResolver EOT received for discovery.
2023-10-18 09:31:56.396 [error] Subprocess exited unsuccessfully with exit code 4 and signal null.
2023-10-18 09:31:56.396 [error] Subprocess exited unsuccessfully with exit code 4 and signal null. Creating and sending error discovery payload
2023-10-18 09:31:56.396 [error] pytest test discovery error
The python test process was terminated before it could exit on its own, the process errored with: Code: 4, Signal: null
2023-10-18 09:31:56.397 [info] ResultResolver EOT received for discovery.
2023-10-18 09:31:56.397 [info] Disposing data receiver for c:\Source\jira-automated-testing and deleting UUID; pytest discovery.
I am getting a little different behaviour with the run and debug of a test that reads in an environment variable.
For simplicity MY_ENV
is replacing the connection string.
{
"configurations": [
{
"name": "Behave: Run all",
"type": "python",
"request": "launch",
"module": "behave",
"args": [
"${workspaceFolder}/app/features"
],
"env": {
"MY_ENV": "smb",
},
"cwd": "${workspaceFolder}"
}
]
}
$env:MY_ENV = "smb"
behave app/features
Not sure whether this is related to the Python Test UI or the Behave Test Adapter.
Python Test UI states that you can use the settings.json
"python.envFile": "${workspaceFolder}/test.env"
to specify a test environment. This works when debugging - but not running.
Both of these approaches work - but only when I debug a test from the Test Explorer. If I click on run alongside a test, it fails.
Scenario: Fooey # app/features/my_feature.feature:3
Given Plop # app/features/steps/my_feature_steps.py:4
When Ploop # app/features/steps/my_feature_steps.py:8
Traceback (most recent call last):
File "c:\dev\code\playground\behave.next-issue\app\.venv\Lib\site-packages\behave\model.py", line 1329, in run
match.run(runner.context)
File "c:\dev\code\playground\behave.next-issue\app\.venv\Lib\site-packages\behave\matchers.py", line 98, in run
self.func(context, *args, **kwargs)
File "app\features\steps\my_feature_steps.py", line 15, in ploop
assert MY_ENV == "smb"
^^^^^^^^^^^^^^^
from behave import given, when, then
import os
@given("Plop")
def plop(context):
print("Plop step executed")
@when("Ploop")
def ploop(context):
print("Ploop step executed")
MY_ENV = f"{os.getenv('MY_ENV')}"
print(f"MY_ENV: {MY_ENV}")
assert MY_ENV == "smb"
print("ok")
@then("Ploooop")
def ploooop(context):
print("Ploooop step executed")
{
"python.defaultInterpreterPath":"${workspaceFolder}/app/.venv/Scripts/python.exe",
"python.terminal.activateEnvironment": true,
"behaveTestAdapter.featuresFolderPath": "${workspaceFolder}/app/features",
"python.envFile": "${workspaceFolder}/test.env"
}
MY_ENV=smb
Any thoughts on this one?
I have VSCode installed on Windows 10:
Version: 1.77.3 (user setup)
Commit: 704ed70d4fd1c6bd6342c436f1ede30d1cff4710
Date: 2023-04-12T09:16:02.548Z
Electron: 19.1.11
Chromium: 102.0.5005.196
Node.js: 16.14.2
V8: 10.2.154.26-electron.0
OS: Windows_NT x64 10.0.19044
Sandboxed: No
I have a folder opened in VSCode containing my project with a venv
setup to run my code against. At the moment I have created a feature file and step file with a simple Given When Then.
When I activate the venv and run the tests by running behave
, I get the output in the terminal.
(.venv) PS C:\dev\code\playground\behave\app> behave
Feature: Foo # features/my_feature.feature:1
Scenario: Foo # features/my_feature.feature:3
Given Plop # features/steps/my_feature_steps.py:4
When Ploop # features/steps/my_feature_steps.py:8
Then Ploooop # features/steps/my_feature_steps.py:12
1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m0.000s
(.venv) PS C:\dev\code\playground\behave\app>
My project looks like this:
├───.vscode
│ settings.json
│
└───app
│ main.py
│ requirements.txt
│
└───features
│ my_feature.feature
│
└───steps
my_feature_steps.py
behave==1.2.6
parse==1.19.0
parse-type==0.6.0
six==1.16.0
{
"python.defaultInterpreterPath":"${workspaceFolder}/app/.venv/Scripts/python.exe",
"python.terminal.activateEnvironment": true,
}
Feature: Foo
Scenario: Foo
Given Plop
When Ploop
Then Ploooop
from behave import given, when, then
@given("Plop")
def plop(context):
print("Plop step executed")
@when("Ploop")
def ploop(context):
print("Ploop step executed")
@then("Ploooop")
def ploooop(context):
print("Ploooop step executed")
Test Explorer UI v2.21.1
Python Test Explorer for Visual Studio Code v0.7.1
Behave Test Explorer v1.0.0
I cannot see tests. I am not sure what I need to put in place to run this extension so I can see the tests.
In the Test Explorer - there are two options: Configure Python Tests
and Install Additional Test Extensions...
. If I click on Configure Python Tests
then only unittest
and pytest
are displayed.
VS Code 1.59 introduced a Test API. It appears to be similar to the Test Explorer UI extension, so I don't think it'd be too difficult to cut over to the built-in API.
https://vscode.trafficmanager.net/api/extension-guides/testing
Given a Scenario Outline with a in its title
When running the example table rows as a tests
Then the title of the test (of the running example table row) should have updated the placeholder from the table rows data
And the number of rows in the example table should equal the number of tests run
So this scenario outline with example:
Scenario Outline: Compute the fibonacci sequence for <count> integers
Given a count of "<count>"
When I call the fib function
Then it should return a sequence "<sequence>"
Examples: Counts
| count | sequence |
| 2 | 1, 1 |
| 5 | 1, 1, 2, 3, 5 |
Should result in these two test:
Compute the fibonacci sequence for 2 integers
Compute the fibonacci sequence for 5 integers
Today it only show
Compute the fibonacci sequence for <count> integers
Hi I cannot view any tests in the test explorer sidebar in VSCode Version: 1.61.2
Version: v0.0.1
process returned an error: pyenv: behave: command not found The `behave' command exists in these Python versions: 3.8.9/envs/wayhome-common-values 3.8.9/envs/wayhomeuk-credit-search-backend wayhome-common-values wayhomeuk-credit-search-backend Note: See 'pyenv help global' for tips on allowing both python2 and python3 to be found.
.vscode/settings.json
{
"terminal.integrated.profiles.osx": {
"zsh": {
"path": "/bin/zsh"
}
},
"terminal.integrated.defaultProfile.osx": "zsh",
"python.defaultInterpreterPath": "/Users/simon/.pyenv/versions/wayhomeuk-credit-search-backend/bin/python",
}
I think the problem is that the extension is not recognising behave
as a command on startup. How do I get behave recommended as a command, i.e. how do I get this plugin to recognise behave as a command from the python virtual environment setup in the python.defaultInterpreterPath workspace setting??
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.