[英]Selenium behave debugging with vscode - python
I have a desktop application made with electron that runs a react project.我有一个使用 electron 制作的桌面应用程序,它运行一个反应项目。 Already exist some test for my application and now I want put them in vscode using for debugging and implement them.我的应用程序已经存在一些测试,现在我想将它们放入 vscode 中用于调试并实现它们。
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.我能够启动我的 exe,加载所有文件(例如,步骤文件中的断点在“Given”行中触发)并调试enviroment.py
文件。 I'm also able (for test) in before_all
function to interact with my app doing actions.我还能够(用于测试)在before_all
function 中与我的应用程序进行交互操作。
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
.我的问题是,当第一次触发before_all
function 和下一个after_all
function 时,其他文件被忽略(功能和步骤)以0 steps passed, 0 failed, 0 skipped, 0 undefined
结尾。
Here is my configuration in launch.json
into .vscode
folder:这是我在launch.json
到.vscode
文件夹中的配置:
{
"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
如果有用,首先在 cmd 中使用以下命令将所有集成到 vscode 中都可以正常工作: behave --no-capture > logs.txt
As foler structure I have作为文件夹结构,我有
root
-> features
-> -> steps
Thanks谢谢
UPDATE 1: more info & code features/enviroment.py更新 1:更多信息和代码功能/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特征/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功能/步骤/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
我总是得到0 features passed, 0 failed, 0 skipped
I found a working solution.我找到了一个可行的解决方案。
"${workspaceFolder}/features" instead "${workspaceFolder}/features/steps" "${workspaceFolder}/features"而不是"${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并用正确的脚本修复了在某些脚本中编辑的os.path目录
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.