【发布时间】:2022-01-07 22:55:06
【问题描述】:
大家好,只是想知道我是否在这里遵循最佳做法。
我有如下步骤定义
public class StepDefinitions {
@DataTableType
public Author authorEntry(Map<String, String> entry) {
return new Author(
entry.get("firstName"),
entry.get("lastName"),
entry.get("famousBook"));
}
@Given("There are my favorite authors")
public void these_are_my_favourite_authors(List<Author> authors) {
// step implementation
}
}
然后我的功能文件可能类似于
Feature: this is a feature
Scenario: this is a scenario
Given There are my favorite authors
|firstName| lastName |
| first | last |
Scenario: this is another scenario
Given There are my favorite authors
|firstName| lastName | famousBook |
| first | last | book |
因此,在第一步中,它将创建一个 Author 对象,但使用 FamousBook == null。
由于我正在创建用于 REST 请求的对象,而 jackson 将忽略空值,是否可以创建这样的对象?
【问题讨论】:
-
可以加
Author类代码吗?
标签: testing automated-tests cucumber bdd qa