With SDK [1.0.0-RELEASE]
1.0.0-RELEASE is a new milestone for ApiHug, and the final ApiHug solution now includes the testing part!
😆 Guide:
kolaTest
during wire protoRefer apihug-demo/libs.versions.toml
{PROJECT_ROOT}/gradle/libs.versions.toml
find apihug = "1.0.0-RELEASE"
please upgrade to 1.0.0-RELEASE
+springBootDependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "springBoot" }
Now by default, kola flag default as false, you need switch @ build.gradle:
hopeWire {
// others...
kola = true
}
You can walk through the sample of apihug-demo//apihug-demo-proto
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", {}
}