Alex Kuznetsov
01/19/2024, 7:27 PM"sequences vs lists" {
//fails
listOf(1, 2, 2, 3) shouldContainExactlyInAnyOrder listOf(1, 2, 3, 3)
}
"sequences vs lists2" {
//passes
sequenceOf(1, 2, 2, 3) shouldContainAllInAnyOrder sequenceOf(1, 2, 3, 3)
}
is that intentional?Alex Kuznetsov
01/19/2024, 7:37 PMI feel confused about containExactlyInAnyOrder
. I'd expect the following to pass, but it fails:
val caseInsensitiveStringEquality: Equality<String> = object : Equality<String> {
override fun name() = "Case Insensitive String Matcher"
override fun verify(actual: String, expected: String): EqualityResult {
return if(actual.uppercase() == expected.uppercase())
EqualityResult.equal(actual, expected, this)
else
EqualityResult.notEqual(actual, expected, this)
}
}
listOf("apple, Apple") should containExactlyInAnyOrder(listOf("APPLE", "APPLE"), caseInsensitiveStringEquality)
what am I missing?CLOVIS
01/21/2024, 2:07 PMdave08
01/23/2024, 12:38 PMTerry Hope
01/23/2024, 8:02 PMMario Niebes
01/25/2024, 9:12 AM1.3.73-233.9802-EAP-CANDIDATE-SNAPSHOT
Was it intended to publish a EAP-CANDIDATE-SNAPSHOT
to everyone?João Gabriel Zó
02/01/2024, 4:56 PMMichael Strasser
02/02/2024, 2:54 AMArb.create(fn)
function in Kotest 5.8.0, even though it is still shown on the Generators List page of the docs.Javier
02/08/2024, 7:26 PMjem
02/12/2024, 7:05 AM"should foo" {
TestApplication().execute {
someFake.bar() shouldBe false
someOtherFake.baz() shouldBe true
}
}
Where TestApplication
contains the fakes and suspend fun execute(f: suspend TestApplication.() -> Unit) = f()
, so that the body has access to any fake it needs.
I'd like to get to
"should foo" {
someFake.bar() shouldBe false
someOtherFake.baz() shouldBe true
}
But I'm finding it very difficult to extend or configure the test to permit this.
Is this kind of thing supported/possible?See Go
02/12/2024, 1:27 PMSortedSet
link
2. add test if this shouldContainExactly supports LinkedHashSet and etc... because when looking at ShouldContainExactlyTest
we can see there are no tests for TreeSet
can I make pr about this improvements?snowe
02/15/2024, 6:18 PMjvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
, but am still getting the
Unable to make field final java.util.Map java.util.Collections$UnmodifiableMap.m accessible: module java.base does not "opens java.util" to unnamed module @4d5d943d
error.
test is pretty simple:
class CompanyIdProviderTest : FreeSpec({
"different environments result in different company ids" {
withEnvironment("ENVIRONMENT", "prod") {
System.getenv("ENVIRONMENT") shouldBe "BarValue" // System environment overridden!
}
}
})
not sure if it’s something with multimodule gradle projects or what…
tasks.withType<Test>().configureEach {
systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
}
tasks.getByName<Test>("test"){
jvmArgs("--add-opens=java.base/java.util=ALL-UNNAMED")
useJUnitPlatform() {
excludeTags("integration", "recording-api")
}
}
Xavier F. Gouchet
02/20/2024, 10:02 AMDescribeSpec
test enabledIf
. This documentation page only mentions this with FreeSpec
styled tests. I can't find what the syntax would be with a describe
or it
method.
"should do something".config(enabledIf = { … }) {
// test here
}
Klitos Kyriacou
02/22/2024, 10:15 AMpackage io.kotest.common
actual fun <K, V> concurrentHashMap(): MutableMap<K, V> = mutableMapOf()
This resulted in me creating a non-concurrent map when I thought it was concurrent.phil-t
02/23/2024, 11:06 AMKlitos Kyriacou
02/25/2024, 4:09 PMbeforeTest
inside a FreeSpec
, is there a way to get a unique identifier of the test being performed? (e.g. a number, 1 being the first test, 2 being the second, or possibly a UUID or similar? I thought of using the hashCode of the test name, but test names don't necessarily have to be unique, and hashCodes of different strings don't have to be unique either.)Mervyn McCreight
03/03/2024, 12:17 PMparallelism
, concurrentSpecs
and concurrentTests
, but somehow I didn't achieve this. There might also be a misunderstanding on my side on what concurrentTests
treats as a test - i'd expect it to try to run every leaf in parallel inside a spec, is that a wrong assumption?Shervin
03/04/2024, 4:26 PMobject
are covered except the first line, the definition of the class:
so object MyObject : Person()
is not covered, while all the inner children are covered.
Any idea how I can resolve this?gavvvr
03/04/2024, 6:15 PMshouldBeSortedBy
transformation is (T) -> E
(without null
support)?
The sortedBy
function from Kotlin stdlib perfectly accepts transformation to potentially null values ((T) -> R?
), where nulls will be treated as "less than any value". I would expected KoTest's shouldBeSortedBy
to behave the same wayklimchuk daniil
03/05/2024, 6:54 PMno answer found for EncryptedSharedPreferencesStorage(#10).set(ACCESS_TOKEN_KEY, null) among the configured answers: (EncryptedSharedPreferencesStorage(#10).set(eq(ACCESS_TOKEN_KEY), null()))
This clearly shows that i'm mocking the method with the called parameters, because they both match
The test code is:
every { prefs.set(ACCESS_TOKEN_KEY, isNull()) } just runs
storage.clear()
verify { prefs.set(ACCESS_TOKEN_KEY, null) }
What am i doing wrong?Kirill Zhukov
03/05/2024, 11:30 PMshould
operator does not print stacktrace on a failure? I have a matcher like this:
fun beEnabled(buttonModel: ButtonModel) =
Matcher<ButtonModel> { model ->
MatcherResult(
buttonModel.isEnabled,
{ "expected $model to be enabled" },
{ "expected $model to not be enabled" }
)
}
fun ButtonModel.shouldBeEnabled(): ButtonModel =
apply {
this should beEnabled(this)
}
On failure shouldBeEnabled
throws assertion error without full stacktrace which makes it hard to figure out where that assertion failed exactly:
java.lang.AssertionError: [REDACTED]
expected ButtonModel(text=Continue, isEnabled=false, isLoading=false, leadingIcon=null, treatment=Primary, size=Footer, testTag=null, onClick=StandardClick(onClick=() -> kotlin.Unit)) to be enabled
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.internal.ScopeCoroutine.afterResume(Scopes.kt:32)
at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:840)
When I change shouldBeEnabled
implementation to this, I get the full stacktrace on failure, am I implementing a custom matcher wrong?
fun ButtonModel.shouldBeEnabled(): ButtonModel =
apply {
this.isEnabled.shouldBeTrue()
}
Adam S
03/07/2024, 4:45 PMIllegalStateException: Nested tests are not supported
sam
03/11/2024, 6:00 AMdave08
03/11/2024, 4:08 PMforAll
allows using suspend funs in it's lambda? It seems like not though... even though forAll itself is a suspend fun...CLOVIS
03/11/2024, 6:20 PM./gradlew jsBrowserRun --info --rerun
, and looking into the generated test report, but it's completely empty. Is that expected?
I'm seeing the same problem in one of my projects, where I cannot see any JS tests being executed, so I wanted to compare with one of the samples to see if it's on my side—but I don't see any tests being executed from the sample either.Adam S
03/12/2024, 7:34 PMgradle :kotest-tests:kotest-tests-js:jsTest
, and see screenshot).
How can I test if my changes have affected Wasm? When I run gradle wasmJsTest
it doesn't trigger anything...Ray Rahke
03/13/2024, 6:13 AM───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ repositories {
2 │ mavenCentral()
3 │ }
4 │ plugins {
5 │ kotlin("jvm") version "1.9.23"
6 │ }
7 │ dependencies {
8 │ testImplementation(kotlin("test"))
9 │ testImplementation 'io.kotest:kotest-runner-junit5:5.8'
10 │ }
11 │ sourceSets {
12 │ test {
13 │ kotlin.srcDirs("test")
14 │ }
15 │ }
16 │
17 │ tasks.withType<Test>().configureEach {
18 │ useJUnitPlatform()
19 │ }
Ray Rahke
03/13/2024, 6:13 AMmickeelm
03/13/2024, 9:36 AMExtension
and Listener
. Listener
is deprecated in favor of Extension
, but the documentation for Extension
promotes Listener
.
I also don't follow the @SoftDeprecated("Use beforeAny")
on the BeforeTestListener
. I mean, I follow/understand the same annotation on beforeTest
, but I don't get why it's on the interface itself.snowe
03/18/2024, 4:59 PM