Giter Site home page Giter Site logo

vscode-bdd-python-test-adapter's People

Contributors

youneselbarnoussi avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

lorthirk

vscode-bdd-python-test-adapter's Issues

pytest test discovery error

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.

Environment variables for behave tests triggered from the Test Explorer?

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.

.vscode/launch.json

{
    "configurations": [
        {
            "name": "Behave: Run all",
            "type": "python",
            "request": "launch",
            "module": "behave",
            "args": [
                "${workspaceFolder}/app/features"
            ],
            "env": {
                "MY_ENV": "smb",
            },
            "cwd": "${workspaceFolder}"
        }
    ]
}

powershell run

$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"
                 ^^^^^^^^^^^^^^^

/app/features/steps/my_feature.py

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")

/.vscode/settings.json

{
    "python.defaultInterpreterPath":"${workspaceFolder}/app/.venv/Scripts/python.exe",
    "python.terminal.activateEnvironment": true,
    "behaveTestAdapter.featuresFolderPath": "${workspaceFolder}/app/features",
    "python.envFile": "${workspaceFolder}/test.env"
}

/test.env

MY_ENV=smb

Any thoughts on this one?

Getting Started - where are my tests

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

venv packages

behave==1.2.6
parse==1.19.0
parse-type==0.6.0
six==1.16.0

.vscode/settings.json

{
    "python.defaultInterpreterPath":"${workspaceFolder}/app/.venv/Scripts/python.exe",
    "python.terminal.activateEnvironment": true,
}

app/features/my_feature.feature

Feature: Foo
    
    Scenario: Foo
        Given Plop
        When Ploop
        Then Ploooop

app\features\steps\my_feature_steps.py

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 Window

image

Extensions

Test Explorer UI v2.21.1
Python Test Explorer for Visual Studio Code v0.7.1
Behave Test Explorer v1.0.0

Where to go now?

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.

Scenario Outline tests don't replace placeholders in title

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

Cannot get behave tests listed using extension

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??

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.