With SDK [1.0.0-RELEASE]
1.0.0-RELEASE 是 ApiHug 一个小里程碑,最终ApiHug 解决方案包含了测试部分!
😆 教程:
kolaTest
测试任务参考 apihug-demo/libs.versions.toml
{PROJECT_ROOT}/gradle/libs.versions.toml
修改: apihug = "1.0.0-RELEASE"
到 1.0.0-RELEASE
+ 版本springBootDependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "springBoot" }
由于尚在测验版本, 默认 kola 没有打开, 参考 build.gradle:
hopeWire {
// others...
kola = true
}
package contracts
import hope.kola.contract.Feature
Feature.make {
priority 100
name("Customer login place order and check balance logic")
description("""Never judge the boss, as you may the real fool""")
Scenario "001 Try login ", {
Given {
api("UserService", "Login")
}
When {
json("""
""")
body {
set('name', "same")
set('student.name', "blue")
set('student.age', 22)
set('student.weight', 123.3d)
set('student.friends', "jake", "blue", "yellow")
set('student.bigBaby', {
addStatement('res.setAge(12)')
addStatement('res.setBlogs($T.asList($S,$S))', Arrays.class, 'jake', 'same')
})
set('student.soreList', 12, 123, 45, Mocker.numberBetween(12, 34))
set('json', Mocker.chineseName().name(), Mocker.cat().name(), Mocker.ip4(), regular("[a-z]"))
}
}
And {
stringAssert("user.address.zipCode", {
isEqualTo("jake")
isBase64()
isAlphabetic()
startsWithIgnoringCase("json")
})
bigDecimalAssert("user.salary", {
isCloseTo(ofBigDecimal("1112.22"), offset(12))
isGreaterThanOrEqualTo(ofBigDecimal("231312"))
})
booleanAssert("user.live", {
isTrue()
})
}
}
Scenario "002 Place a order", {}
Scenario "003 Check balance", {}
}