I have a desktop application made with electron that runs a react project. Already exist some test for my application and now I want put them in vscode using for debugging and implement them.
I am able to launch my exe, load all files (for example the breakpoints in the step files fires in the "Given" line) and debug the enviroment.py
file. I'm also able (for test) in before_all
function to interact with my app doing actions.
My problem is that as first fires before_all
function and next after_all
function, other files are ignored (features and steps) ending with a 0 steps passed, 0 failed, 0 skipped, 0 undefined
.
Here is my configuration in launch.json
into .vscode
folder:
{
"name": "Python: all",
"type": "python",
"request": "launch",
"module": "behave",
"console": "integratedTerminal",
"args": [
"--no-capture",
"--no-capture-stderr",
"${workspaceFolder}/features/steps"
]
}
If can be useful, first the integration into vscode all works fine using the following command in cmd: behave --no-capture > logs.txt
As foler structure I have
root
-> features
-> -> steps
Thanks
UPDATE 1: more info & code features/enviroment.py
#..imports..
apiPath = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if apiPath not in sys.path:
sys.path.append(apiPath)
def before_all(context):
#..code..
context.my_app.open_app()
sleep(2)
context.queries_logger = logging.getLogger('MainThread')
context.queries_logger.setLevel(logging.INFO)
context.formatter = logging.Formatter('%(asctime)-15s %(threadName)-15s'
' %(levelname)-8s %(module)-15s:%(lineno)-8s %(message)s')
def before_feature(context, feature):
#..code.. NEVER RUNS!
def after_all(context):
context.my_app.close_app()
features/blabla.feature
Feature: Test of the parameters configuration of the XXX
@XXX_XX @wip
Scenario: User sets ...
Given User add a XXXXX in the configuration file
When User enters in the ....
Then User checks that .....
features/steps/blabla.step
from time import sleep
from behave import *
@Given("User add a XXXXX in the configuration file")
def add_xxxxxxx(context):
#NEVER RUNS!
@When("User enters .....")
def enter_xxxxxx(context):
#NEVER RUNS!
@Then("User checks .......")
def check_xxxxx(context):
#NEVER RUNS!
and I always get 0 features passed, 0 failed, 0 skipped
I found a working solution.
"${workspaceFolder}/features" instead "${workspaceFolder}/features/steps"
{
"name": "Python: all",
"type": "python",
"request": "launch",
"module": "behave",
"console": "integratedTerminal",
"args": [
"--no-capture",
"--no-capture-stderr",
"${workspaceFolder}/features"
]
}
and fixed the os.path directory that was edited in some script with the right one