我可以将定义的机器人关键字放在机器人框架中的套件设置/测试设置下吗
我是编码和机器人框架的新手,如果我的方法不适用,请有人向我解释一下。
我的目标是做一个测试设置来创建一个游戏作为先决条件,以便让所有玩家加入同一个游戏。否则,机器人将循环遍历我的关键字,每次都需要为下一个玩家创建一个新游戏才能加入,这是我想避免的情况。
但是,测试设置似乎不允许我放置自己定义的机器人关键字并引发错误,有人可以建议吗?
#Create Trading Arena Game
When Create trading arena game name as ${game_name} with status ${status} where start date on ${minutes_to_start} and end date on ${day_to_end} open for vip tiers ${vip_tiers} and user type ${user_type} and trade filter ${instrument_pair} by wallet ${wallet_type} with min trade volume ${min_trade_volume} and leaderboard ${is_with_leaderboard}
When Wait 60000 millisecond
#Error log
Using local env settings...
==============================================================================
001.Vip Tiers Join Trading Arena Game
==============================================================================
Level 1 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 2 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 3 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 4 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 5 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 6 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 7 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 8 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 9 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
001.Vip Tiers Join Trading Arena Game | FAIL |
Suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
*** Settings ***
Resource ../../../robot_resources/Common.robot
Resource ../../../robot_resources/Assertion.robot
Test Template Different vip tiers of user join trading arena game
Test Setup Create Trading Arena Game
*** Variables ***
${record_number} 1
${user_1} 1
${user_2} 2
${user_3} 3
${user_4} 4
${user_5} 5
${user_5} 6
${user_5} 7
${user_5} 8
${user_5} 9
${game_name} Test vip tiers level join trading game
${status} ACTIVE
${minutes_to_start} 1
${day_to_end} 30
${vip_tiers} 1,2,3,4,5,6,7,8,9
${user_type} INDIVIDUAL
${instrument_pair} BTC,USDT
${wallet_type} SPOT
${min_trade_volume} 0
${is_with_leaderboard} true
${status2} ENDED
${vip_tiers2} ${EMPTY}
${user_type2} ${EMPTY}
${instrument_pair2} ${EMPTY}
${wallet_type2} ${EMPTY}
${min_trade_volume2} ${EMPTY}
${is_with_leaderboard2} ${EMPTY}
*** Test Cases ***
Level 1 user join trading arena game ${user1} ${checking}
Level 2 user join trading arena game ${user2} ${checking}
Level 3 user join trading arena game ${user3} ${checking}
Level 4 user join trading arena game ${user4} ${checking}
Level 5 user join trading arena game ${user5} ${checking}
Level 6 user join trading arena game ${user6} ${checking}
Level 7 user join trading arena game ${user7} ${checking}
Level 8 user join trading arena game ${user8} ${checking}
Level 9 user join trading arena game ${user9} ${checking}
*** Keywords ***
Create Trading Arena Game
When Create trading arena game name as ${game_name} with status ${status} where start date on ${minutes_to_start} and end date on ${day_to_end} open for vip tiers ${vip_tiers} and user type ${user_type} and trade filter ${instrument_pair} by wallet ${wallet_type} with min trade volume ${min_trade_volume} and leaderboard ${is_with_leaderboard}
When Wait 60000 millisecond
Different vip tiers of user join trading arena game
[Arguments] ${user} ${checking}
When Get latest ${record_number} trading arena game records on ${status}
When Wait 5000 millisecond
When Get latest ${record_number} trading arena game records with user eligibility on ${status} of ${user}
When Wait 5000 millisecond
When Player join latest ${record_number} trading arena game with tiers level ${user}
When Wait 5000 millisecond
Then Should actual result "${user_join_trading_arena_game_record}" match expected "${checking}" result
I am new to coding and robot framework, Could anyone please kindly explain to me if my approach down here is not applicable.
My goal would like to do a test setup to create a game as prerequisties in order to let all players to join the same game. Otherwise, robot will loop through my keywords and each time will need to create a new game for the next player to join, which is the case I would like to avoid.
However, it seems that Test Setup doesn't allow me to put my own defined robot keywords and throwing errors, could anyone kindly advise?
#Create Trading Arena Game
When Create trading arena game name as ${game_name} with status ${status} where start date on ${minutes_to_start} and end date on ${day_to_end} open for vip tiers ${vip_tiers} and user type ${user_type} and trade filter ${instrument_pair} by wallet ${wallet_type} with min trade volume ${min_trade_volume} and leaderboard ${is_with_leaderboard}
When Wait 60000 millisecond
#Error log
Using local env settings...
==============================================================================
001.Vip Tiers Join Trading Arena Game
==============================================================================
Level 1 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 2 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 3 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 4 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 5 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 6 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 7 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 8 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
Level 9 user join trading arena game | FAIL |
Parent suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
------------------------------------------------------------------------------
001.Vip Tiers Join Trading Arena Game | FAIL |
Suite setup failed:
Keyword 'Create Trading Arena Game' expected 0 arguments, got 10.
*** Settings ***
Resource ../../../robot_resources/Common.robot
Resource ../../../robot_resources/Assertion.robot
Test Template Different vip tiers of user join trading arena game
Test Setup Create Trading Arena Game
*** Variables ***
${record_number} 1
${user_1} 1
${user_2} 2
${user_3} 3
${user_4} 4
${user_5} 5
${user_5} 6
${user_5} 7
${user_5} 8
${user_5} 9
${game_name} Test vip tiers level join trading game
${status} ACTIVE
${minutes_to_start} 1
${day_to_end} 30
${vip_tiers} 1,2,3,4,5,6,7,8,9
${user_type} INDIVIDUAL
${instrument_pair} BTC,USDT
${wallet_type} SPOT
${min_trade_volume} 0
${is_with_leaderboard} true
${status2} ENDED
${vip_tiers2} ${EMPTY}
${user_type2} ${EMPTY}
${instrument_pair2} ${EMPTY}
${wallet_type2} ${EMPTY}
${min_trade_volume2} ${EMPTY}
${is_with_leaderboard2} ${EMPTY}
*** Test Cases ***
Level 1 user join trading arena game ${user1} ${checking}
Level 2 user join trading arena game ${user2} ${checking}
Level 3 user join trading arena game ${user3} ${checking}
Level 4 user join trading arena game ${user4} ${checking}
Level 5 user join trading arena game ${user5} ${checking}
Level 6 user join trading arena game ${user6} ${checking}
Level 7 user join trading arena game ${user7} ${checking}
Level 8 user join trading arena game ${user8} ${checking}
Level 9 user join trading arena game ${user9} ${checking}
*** Keywords ***
Create Trading Arena Game
When Create trading arena game name as ${game_name} with status ${status} where start date on ${minutes_to_start} and end date on ${day_to_end} open for vip tiers ${vip_tiers} and user type ${user_type} and trade filter ${instrument_pair} by wallet ${wallet_type} with min trade volume ${min_trade_volume} and leaderboard ${is_with_leaderboard}
When Wait 60000 millisecond
Different vip tiers of user join trading arena game
[Arguments] ${user} ${checking}
When Get latest ${record_number} trading arena game records on ${status}
When Wait 5000 millisecond
When Get latest ${record_number} trading arena game records with user eligibility on ${status} of ${user}
When Wait 5000 millisecond
When Player join latest ${record_number} trading arena game with tiers level ${user}
When Wait 5000 millisecond
Then Should actual result "${user_join_trading_arena_game_record}" match expected "${checking}" result
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,我相信您需要一个
套件设置
而不是测试设置
,它会在所有测试用例开始之前创建游戏,而不是创建第二,
套件设置
允许用户定义关键字,但您将参数传递到创建交易竞技场游戏
在当创建交易竞技场游戏名称为$ {game_name} ...
而关键字不接受任何参数。不知道为什么您要重复使用创建交易竞技场游戏
下的关键字。First, I believe you would want a
Suite Setup
instead ofTest Setup
which would create the game before all test case starts, instead of creating the game before each test case startsSecond,
Suite Setup
allows user defined keyword but you are passing arguments intoCreate Trading Arena Game
atWhen Create trading arena game name as ${game_name} ...
while the keyword does not accept any arguments. Not sure why you are recusing the keyword underCreate Trading Arena Game
.