Piotr Krzemiński
10/04/2023, 6:23 AMKonsist.scopeFromProduction()
.withModifier(KoModifier.DATA)
.properties(includeNested = true, includeLocal = true)
.assertNot {
it.hasValModifier
}
one thing is that there's .classes()
missing after getting the scope (I'll report it to the author), but even after adding it, I'm getting this when running the test:
java.lang.ClassCastException: class org.jetbrains.kotlin.idea.KotlinFileType cannot be cast to class com.intellij.openapi.fileTypes.FileType (org.jetbrains.kotlin.idea.KotlinFileType and com.intellij.openapi.fileTypes.FileType are in unnamed module of loader 'app')
at com.lemonappdev.konsist.core.util.KotlinFileParser.getKtFile(KotlinFileParser.kt:42)
A full reproducer is here. Am I doing something wrong?PoisonedYouth
10/04/2023, 7:05 AMKonsist.scopeFromProduction()
.classes()
.withModifier(KoModifier.DATA)
.properties(includeNested = true, includeLocal = true)
.assert {
it.hasValModifier
}
Piotr Krzemiński
10/04/2023, 7:06 AMclasses()
? do you have a clue why it may not work in my case?PoisonedYouth
10/04/2023, 7:09 AMPiotr Krzemiński
10/04/2023, 7:09 AMapp
module - maybe it’s about this?PoisonedYouth
10/04/2023, 7:19 AMigor.wojda
10/05/2023, 4:32 AMassertNot
.assertNot {
it.hasValModifier
}
which means you are asserting that these declarations don't have val
modifier.
Just change it to assert
and test will run
.assert {
it.hasValModifier
}
BTW In upcoming release these assertion will be renamed to assertTrue
and assertFalse
PoisonedYouth
10/05/2023, 4:46 AMigor.wojda
10/05/2023, 5:12 AM2192
properties 🚀
2. Konsist is not displaying right name for the KoTest test for ki tests ..Assert 'invokeSuspend' was violated (2192 times)...
(will be fixed in next release)
3. It looks like Gradle cuts the logs (they are not full)
I am unable to reproduce class cast exception issue after checking out this project - long story short some Kotlin file can't be parsed 🤔 (I guess they may be in some temp/build dir). @Piotr Krzemiński can make this cast problem reproducable on your side, zip entire project and send it my way?Piotr Krzemiński
10/05/2023, 6:31 AMigor.wojda
10/05/2023, 10:42 AMgithub-workflows-kt/library/build/reports/tests/test/index.html
(this artifact contains a complete log for failing test)
BTW KoTest support is coming, soon so you will be able to see meaningful method names in crash logsPiotr Krzemiński
10/05/2023, 11:02 AMbuild/reports/tests/test/index.html
can be retrieved there somehow?com.lemonappdev.konsist.core.exception.KoCheckFailedException: Assert 'invokeSuspend' was violated (2192 times).
here which looks like a false positiveigor.wojda
10/05/2023, 2:37 PMassertNot
instead of assert
build/reports/tests/test/index.html
from CI you have to store it as build artifact
- uses: actions/upload-artifact@v3
with:
name: dokka-html-doc.jar
path: ./build/reports/tests/*
PoisonedYouth
10/05/2023, 3:06 PMPiotr Krzemiński
10/05/2023, 3:19 PMigor.wojda
10/05/2023, 4:22 PMPoisonedYouth
10/06/2023, 2:03 PMigor.wojda
10/06/2023, 2:13 PMPoisonedYouth
10/06/2023, 5:27 PMLightVirtualFile
has a parameter of type com.intellij.openapi.fileTypes.FileType
but KotlinFileParser
is providing org.jetbrains.kotlin.idea.KotlinFileType
. That does not make sense. I made some tests with Kotest but was not able to reproduce the issue in any of my private projects.igor.wojda
10/08/2023, 7:25 PMNoClassDefFoundError
- I have no idea whats going on, but I am hoping that Kotest community will help. For now it looks like cmd run works, you cna run all tests from class using IDE, however single test run may fail.
https://kotlinlang.slack.com/archives/CT0G9SD7Z/p1696872615996559Piotr Krzemiński
10/09/2023, 6:32 PMigor.wojda
10/09/2023, 7:14 PM