我刚刚安装了 Freshen,正在尝试掌握它的窍门。
下面的测试运行,但它给出的输出不正确。
测试:get_user.feature
Feature: Retrieve an existing User
When a Users ID (ID, Email, User-name) is entered,
An object containing all the Users information is returned
Scenario: Get existing User from their ID
Given I have the user where their id is '288' and account id is '57'
Then their username should equal adminuserxxx
步骤.py
from freshen import *
from freshen.checks import *
import user_operations
import util
#The URL of the API
api_root = "http://api.stuff.com/v1/core";
#The ID of the Application
appid = "1234567";
#Our private key
secret = "987654321";
#Headers
headers = {'Accept':'application/json', 'Content-Type':'application/json'}
@Before
def before(sc):
scc.headers = headers
util.get_auth_token_and_scope(api_root, appid, secret, scc.headers) #An authorization token is added to scc.headers here
@Given("I have the user where their id is (\d+) and account id is (\d+)")
def enter(user_id,account_id):
scc.user = user_operations.get_user_from_id(int(account_id), int(user_id), scc.headers)
@Then("their (\w+) should equal (\w+)")
def check_result(field_value, result):
assert_equal(str(result),scc.user[str(field_name)])
控制台输出:
C:\Users\Front-End>nosetests --with-freshen -v features\
Retrieve an existing User: Get existing User from their ID ... UNDEFINED: "I hav
e the user where their id is '288' and account id is '57'" # features\get_user.f
eature:6
----------------------------------------------------------------------
Ran 1 test in 0.137s
OK (UNDEFINED=1)
有人能指出我做错了什么吗?干杯!
最佳答案
如果您在 @Given 函数中使用 (\d+) ...(\d+),该功能应该具有这种语法(假设我有用户,他们的 ID 是 288 并且帐户 ID 是 57)
M.Harbaoui
关于python - 不正确的清新使用测试结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21142074/