About Kola

Latest

⚠️Always keep your SDK & IDEA to latest version⚠️

Timeline

Sine ApiHug [1.0.0-RELEASE] - 2024-08-02

Features

  • DSL style BDD definition, follow consumer driven test - Contract test principle
  • introduce new task kolaTest during wire proto
  • Seamlessly integrates all existing testing solutions (JUnit5, AssertJ, etc.)

Upgrade steps

Refer apihug-demo/libs.versions.toml

  1. Upgrade ApiHug SDK: {PROJECT_ROOT}/gradle/libs.versions.toml find apihug = "xxx" please upgrade to 1.0.0-RELEASE+
  2. Add new lib reference: springBootDependencies = { group = "org.springframework.boot", name = "spring-boot-dependencies", version.ref = "springBoot" }

⚠️ Add of springBootDependencies is MUST, otherwise the wire compile may report:

Could not get unknown property 'springBootDependencies' for extension 'libs' of type org.gradle.accessors.dm.LibrariesForLibs.

Now by default, kola flag default as false, you need switch @ build.gradle:

hopeWire {
    // others...
    kola = true
}

Sample

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", {}
}