[智能体-262]:RAG 文档切块(Transform 文本拆分):拆分背景、缘由、主流拆分策略
2026/6/5 3:29:56
在测试中,Mock是Stub的超集,这意味着所有Stub的功能Mock都具备。例如下面的代码,使用Mock来实现“如果仓库为空,则无法发货”的测试:
def "If warehouse is empty nothing can be shipped"() { given: "a basket and a TV" Product tv = new Product(name:"bravia",price:1200,weight:18) Basket basket = new Basket() and:"an empty warehouse" WarehouseInventory inventory = Mock(WarehouseInventory) inventory.isEmpty() >> true basket.setWarehouseInventory(inventory) when: "user checks out the tv" basket.addProduct tv then: "order cannot be shipped" !basket.canShipCompletely() }在Spock中,当你只需要一个具有预编程行为且不需要验证交互的假类