-
Notifications
You must be signed in to change notification settings - Fork 352
Introduce (reflective) Arb testing with Kotest #10880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ testing { | |
implementation(project(":utils:test-utils")) | ||
|
||
implementation(libs.kotest.assertions.core) | ||
implementation(libs.kotest.property) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just curious: What is the experiment after? What is the unkown and how can we make use of outcome? I've a bit doubts that generating "meaningful" test data, is valuable for parameter values which do not matter. E.g. the need to emphasize (by using arbs) could also be a code smell hinting at suboptimal clarity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I see it pretty much as the opposite: Arb (which is short for "arbitrary") deliberately creates "unmeaningful" test data to emphasize that the test should work for any value, and not just for the hard-coded one. This also creates a chance to uncover edge-case bugs in tests where a test only works for an existing hard-coded value, whereas it should generally work. It's a little bit like fuzzing. So I see it as clarity being added by deliberately using arbitrary / random values.
Eventually, I hope to get rid of e.g. some There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM, but let's get a second approval. |
||
implementation(libs.kotest.runner.junit5) | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,9 @@ | |
import io.kotest.matchers.should | ||
import io.kotest.matchers.shouldBe | ||
import io.kotest.matchers.string.haveSubstring | ||
import io.kotest.property.Arb | ||
import io.kotest.property.arbitrary.file | ||
import io.kotest.property.arbitrary.single | ||
|
||
|
||
import java.io.File | ||
|
||
|
@@ -39,7 +42,7 @@ | |
class ComposerFunTest : StringSpec({ | ||
"Project files from vendor directories are ignored" { | ||
val projectFiles = ComposerFactory.create().mapDefinitionFiles( | ||
File("."), | ||
Arb.file().single(), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mnonnenmacher, I found a little bit of a nicer syntax here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better, but if Kotest would provide a function like |
||
listOf( | ||
"projectA/composer.json", | ||
"projectA/vendor/dependency1/composer.json", | ||
|
Uh oh!
There was an error while loading. Please reload this page.