Spock企业测试特性及大测试处理策略
1. Spock额外注解
在Spock测试中,有一些额外的注解能为测试带来便利。
1.1 @Requires注解
当你发现自己总是要反转 @IgnoreIf 注解内的条件时,可以使用 @Requires 注解。例如:
@Requires({ new CreditCardProcessor().online() })
def "credit card charge happy path"() {
given: "a basket, a customer and a TV"
Product tv = new Product(name:"bravia",price:1200,weight:18)
BillableBasket basket = new BillableBasket()
Customer customer = new
Customer(name:"John",vip:false,creditCard:"testCard")
and: "a credit card service"
CreditCardProcessor creditCardSevice = new CreditCardProcessor()
basket.setCreditCardProcessor(creditCardSevice)
when: "user checks out the tv"
b
超级会员免费看
订阅专栏 解锁全文
823

被折叠的 条评论
为什么被折叠?



