Michael Strasser
03/29/2022, 10:32 PMmitch
03/30/2022, 5:54 AMtest("should print out failing inputs and shrinks when a function throws") {
suspend fun functionThatUnexpectedlyThrows() { throw RuntimeException("aaaa") }
checkAll(Arb.bigInt(4, 4)) { value ->
functionThatUnexpectedlyThrows()
}
}
and then I realized that we don’t report the inputs or attempt any shrinking to the users when the exception is not kotest’s assertion errs. i.e.
Property failed after 1 attempts
java.lang.AssertionError: Property failed after 1 attempts
Repeat this test by using seed 320358835705021305
Caused by RuntimeException: aaaa
if that function was wrapped around shouldNotThrowAny { .. }
then that’ll print out the inputs and properly shrunk it.
it’s written here
https://github.com/kotest/kotest/blob/aba6984d6a08530e931274f7a9f6e3b62a66b681/kot[…]perty/src/commonMain/kotlin/io/kotest/property/internal/test.kt
is this by design? or should we fix that?
if you reckon that’s a bug i can raise an issue and raise a fix PR?André Martins
04/01/2022, 9:14 AMfun Arb.Companion.student(): Arb<Student> = arbitrary { rs ->
Student(
id = Arb.uuid(V4,false).next(rs)
name = Arb.string().next(rs),
number = <http://Arb.int|Arb.int>().next(rs), ...
)
}
What can I add here to lock the number I which my generated student have?
Arb.student().<here>?
// Something like
Arb.student().with(number, 123)
Anyway I can do this?LeoColman
04/02/2022, 5:48 PMshouldBeFailure
, the error message I get is
java.lang.AssertionError: Result should be a failure but was kotlin.UnitWhile I actually expected it to be more significant that it's a Success, like:
java.lang.AssertionError: Result should be a failure but was Success(kotlin.Unit)This is due to the fact that
BeFailure
uses getOrNull
in the Result
instead of toString
. I think it would be better to replace it, but I don't know. What do you think? I can open an issue to discuss this further in the Kotest repositoryJames Eschner
04/04/2022, 9:32 PMclass ProjectConfig : AbstractProjectConfig() {
override fun listeners(): List<TestListener> = listOf(SystemEnvironmentProjectListener("foo", "bar"))
}
but AbstractProjectConfig::listeners is deprecated and the deprecation message, “`Use extensions."` , isn’t the most helpful. I would like to define the listener once for the whole project.
* Not a contribution *julian
04/05/2022, 2:09 AMPeter
04/05/2022, 7:35 AM5.2.2
- i think it may be related to the new 1.6.1
coroutine release from yesterday?wasyl
04/05/2022, 8:24 PMiamsteveholmes
04/06/2022, 3:53 PMiamsteveholmes
04/06/2022, 3:58 PMtim
04/11/2022, 8:45 AMRuntime.getRuntime().addShutdownHook(…)
but was curious if there’s something exposed by kotest to more easily accomplish this?Big Chungus
04/11/2022, 11:31 AMmcpiroman
04/11/2022, 4:19 PMRichard Gomez
04/11/2022, 7:40 PMconfirmVerified
or unmockX()
between cases. 🧵Min Tikim
04/11/2022, 8:27 PMalightgoesout
04/12/2022, 5:09 PMFilip Piechowski
04/13/2022, 9:40 AMTestFactory
builder, that would nest further steps declared by user in a lambda as the last parameter of my test factory.
In my specific case that would look like this:
class MySpec : FreeSpec({
include(replicatorSpec(...) { // this: ReplicatorTestFactoryConfiguration extending TestFactoryConfiguration(), FreeSpecRootScope
parent(...) { // this: ReplicatorTestFactoryConfiguration.AfterParent extending TestFactoryConfiguration(), FreeSpecRootScope
create(...) { // this: ReplicatorTestFactoryConfiguration.AfterCreate extending TestFactoryConfiguration(), FreeSpecRootScope
update(...)
}
}
)}
})
inline fun RootScope.replicatorSpec(
...,
crossinline configure: ReplicatorTestFactoryConfiguration.() -> Unit = { }
) = freeSpec {
<http://logger.info|logger.info> { "replicatorSpec" }
beforeSpec {...}
val configuration = ReplicatorTestFactoryConfiguration(...)
configuration.configure()
afterSpec {...}
}
inline fun ReplicatorTestFactoryConfiguration.parent(
... ,
crossinline then: ReplicatorTestFactoryConfiguration.AfterParent<P>.() -> Unit = {}
) { ... }
inline fun ReplicatorTestFactoryConfiguration.AfterParent.create(
... ,
crossinline then: ReplicatorTestFactoryConfiguration.AfterParent<P>.AfterCreate<P, COUT>.() -> Unit = { }
) { ... }
inline fun ReplicatorTestFactoryConfiguration.AfterParent.AfterCreate.update(...) { ... }
But when running tests and putting debug FreeSpec test scopes ("debug" - { }
) i see that execution gets only to the replicatorSpec(...)
and the FreeSpecScopes defined in there, but anything further like the code defined in lambda. How can I create such aLidonis Calhau
04/14/2022, 2:41 PMshouldContainJsonKeyValue("key", false) or shouldNotContainJsonKeyValue("key")
peekandpoke
04/18/2022, 8:12 AM"FAIL!" {
fail("BOOOM!")
}
I still see all tests being successful.
The test suite also worked last week and the JS and Common tests where executed properly and suddenly stopped doing so. Does anyone have an idea what is wrong here.
I am running on Ubuntu 20.04 and Kotest 5.2.3, Kotlin 1.6.20. I also know that my browsers where updated last week...
So yeah am I lost here. Any help, ideas or pointers is very much appreciated!thana
04/18/2022, 9:31 AMsam
04/18/2022, 12:09 PMthana
04/18/2022, 3:50 PMchristophsturm
04/19/2022, 8:36 AMAndré Martins
04/21/2022, 9:37 AMdata class Student(val id: Int, val name: String)
and I’m trying to build a Arb of Student like
fun Arb.Companion.student(
id: Arb<Int> = positiveInt(),
name: Arb<String> = string()
): Arb<Student> = arbitrary { rs ->
Student(
id.next(rs),
name.next(rs) // or name.bind() and ignore rs?
)
}
Should I call bind
or next
with the current randomSource?James Eschner
04/21/2022, 2:44 PMAdam S
04/30/2022, 8:05 AMPOST /user/create
that GET /user/{id}
works) is possible too.
The benefits of this would be
• the OpenAPI spec drives the testing, and would be completely separate from the codebase (no need for spec or code generation, which is always limiting)
• there's no limitation or restriction on how to implement the API (for example Hikaku doesn't handle many custom implementations)
• because the spec can be tested, it would always be up-to-date.
I've attached a mock code example. I might work on a proof-of-concept...benkuly
05/03/2022, 12:14 PMJuan B
05/04/2022, 7:23 AMNot enough information to infer type variable T
io.kotest.extensions.testcontainers.TestContainerExtension public constructor TestContainerExtension<T : GenericContainer<out T>>(
container: GenericContainer<out T>,
lifecycleMode: LifecycleMode
)
Adding the test code in the thread 👇
Thanks for any help!!Rob Elliot
05/05/2022, 4:04 PMMap<K, V>.shouldContainAll(expected: Map<K, V>)
which recurses into any maps in the top level structure?peekandpoke
05/12/2022, 2:07 PMpeekandpoke
05/12/2022, 2:07 PMSam
05/12/2022, 2:11 PMpeekandpoke
05/12/2022, 2:12 PMkotlinx-coroutines-core.1.6.1
And my lib pulls kotlinx-coroutines-core.1.6.0
Somehow the compiler does not remove the smaller version from the icCacheMap
which some steps later results in the NPE.kotlinx-coroutines-core.1.6.1
the errors is gone.