假设我有一个 Python 库来操作博客文章:
class BlogPost(object):
def __init__(self):
...
def create_a_blog_post(self):
...
def add_category(self, category):
...
def add_title(self, title):
...
我想要以下测试用例:
*** Test Cases ***
Create post with category
Create a blog post with category "myCategory"
Create post with title
Create a blog post with title "myTitle"
Create post with both
Create a blog post with category "myCategory" and title "myTitle"
我应该为只有类别、只有标题和两者都创建单独的用户关键字吗?或者无论如何要为关键字添加任意数量的“修饰符”?
另外,如果我们必须将一个关键字的结果传递给另一个关键字,如何创建这样的关键字:
*** Keywords ***
Create a blog post with category
Create a blog post
Add category <-- How do I pass the blog post I just created to "Add category"
我故意省略了示例中的参数处理,因为这不是重点:)