Property testing extension for Protobuf using kotest-property
. You can generate random protobuf messages using
Arb.protobufMessage<...>()
call and customize the generation properties.
Include the dependency inside build.gradle.kts
.
dependencies {
testImplementation("io.github.dogacel:kotest-property-protobuf:LATEST")
}
Use the Arb
generators provided by the module to generate random protobuf classes.
import dogacel.kotest.ProtobufMessageArb.protobufMessage
class SampleProtobufTest : FunSpec({
test("should convert without errors") {
val settings = ProtobufMessageArbSettings(fieldPresenceProbability = 0.80)
Arb.protobufMessage<FooMessage>(settings).forAll { protoMessage ->
val sut = convert(protoMessage)
// Do some validation
sut.id == protoMessage.id && sut.name == (protoMessage.firstName + protoMessage.lastName)
}
}
})
For configuring the generation settings, check ProtobufMessageArbSettings
class.
- Allow generation of random protobuf messages.
- Generate realistic well-known types. (I.e. generate timestamps in ±50 years)
- Allow customizing generation settings per field.
- Support protovalidate rules.
Note
This section is applicable to official maintainers only.
- Update
version
under rootbuild.gradle.kts
. - Make sure you set
SONATYPE_USERNAME
,SONATYPE_PASSWORD
,GPG_SIGNING_KEY
andGPG_SIGNING_PASSPHRASE
. ./gradlew publishToSonatype
./gradlew findSonatypeStagingRepository closeSonatypeStagingRepository
./gradlew findSonatypeStagingRepository releaseSonatypeStagingRepository
For any errors, visit https://s01.oss.sonatype.org/#stagingRepositories.
After you release a -SNAPSHOT
version, you need the following block to import it.
repositories {
maven {
this.url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}
For starters, start by checking issues.
Linting can be done via
``./gradlew ktlintFormat
Building the whole project,
./gradlew build
Check coverage of the code,
./gradlew koverHtmlReport
Please feel free to open issues and PRs.