我正在使用pytest-bdd
这是我的功能文件
#recon_test.feature
Feature: This is used to run recon
Scenarios:Run Recon测试文件‘python #recon_test.py
Class Recon_Tests():
@scenario('recon_test.feature','Run Recon')
def test_run_recon(self):
#do somethingwhen i run this using command pytest , i get error **fixture 'self' not found.**
Because due to scenario annotation it treats this function as fixture maybe , and expects **'self'** to be another fixture.
I want to use the '@scenario' in my test functions inside the test classes . Is there any way ?
Also , i have found a workaround for this , i have created a fixture
```pythondef self():
经过
来避免这种情况,错误就消失了。
但是它给出了另一个错误,指出'Recon_Tests‘没有属性配置。
因为bdd试图读取fixture的配置对象以获取测试前钩子。
请给出建议
发布于 2021-07-26 21:49:57
这是因为pytest无法知道它是self (就类实例而言)还是fixture。
当你从unittest.TestCase继承你的类时,这个问题就被修复了。这意味着您可以指定class ReconTests(unittest.TestCase)而不是class Recon_Tests()。
https://stackoverflow.com/questions/63629643
复制相似问题