Peter
10/22/2024, 12:08 PMKonsist.scopeFromModule("app")
.assertArchitecture {
val profile = Layer("profile", "com.some.app.profile..")
val auth = Layer("auth", "com.some.app.auth..")
profile.dependsOn(auth)
auth.dependsOn(profile)
}
Blaž Vantur
10/23/2024, 8:07 AMTim Malseed
10/24/2024, 11:35 AMigor.wojda
10/25/2024, 11:56 AMNatalia Peterwas
10/28/2024, 12:10 PMDominik
10/30/2024, 10:11 AMFooClass
and an enum BarEnum
.
class FooClass {
val enum: BarEnum = BarEnum.BAR
}
enum class BarEnum {
BAR
}
Now what I need to figure out is:
Does FooClass
contain a property of any Enum
type?
Happy for any ideas/input.Eugen Martynov
11/04/2024, 10:13 AMYerdaulet
11/22/2024, 7:32 AM//thing to check
suspend fun getAccounts(
@Query("account") account: String,
): ApiResult<AccountDto>
//test
apiInterfacesScope
.assertTrue {
it.hasFunction { function ->
function.returnType?.asInterfaceDeclaration()?.name == "ApiResult"
}
}
but my code doesn't workRasmus Larsen
11/22/2024, 12:30 PMhasPublicOrDefaultModifier
for this. But functions within an internal class will return hasPublicOrDefaultModifier=true.
Is there anything I can do to test this?
Code sample added in comments.igor.wojda
11/25/2024, 10:23 AMMario Niebes
11/26/2024, 3:47 PMdependsOn
is now (v0.17.0) changed from "may depend on" to "has to depend on". Is this intended?igor.wojda
11/30/2024, 7:47 PMigor.wojda
12/02/2024, 4:53 PMAmitoj Duggal
12/04/2024, 11:22 AMInvalid package definition for layer 'Adapter DTOs'. Package can only end with '..'
We have layers defined like this, which worked well with 0.16
val adapterDtos = Layer("Adapter DTOs", "$basePackage.adapter..dto..")
I see that some package-related changes were reverted in 0.17.1. Though this seems to be the current behaviour, is it an intended breaking change?Eric
12/18/2024, 2:59 PMtoString
?
@MethodSource("entityClasses")
@ParameterizedTest(name = "test {1} child collections that are not an immutable Set have @OneToMany(orphanRemoval = true)")
fun `test entities mutable child collections have @OneToMany(orphanRemoval = true)`(
entityClass: Class<*>,
className: String,
) {
expectThat(entityClass.kotlin.declaredMemberProperties)
.filter { it.returnType.isSubtypeOf(Collection::class.starProjectedType) }
.filterNot { it.returnType.toString().startsWith("kotlin.collections.Set") }
.map { requireNotNull(it.javaField).getAnnotation(OneToMany::class.java) }
.all { get { orphanRemoval }.isTrue() }
}
buszi0809
12/23/2024, 8:44 AM0.15.1
to 0.17.3
and wanted to confirm it is not an issue on my side
I have a test case where I verify that classes that have UseCase as parent interface reside in .impl
package of this parent interface, basically verifying that use case implementations are placed in correct package in relation to the interface definition
before migration it looked like this:
Konsist.scopeFromProject()
.classes()
.withParent { it.hasNameEndingWith("UseCase") }
.assertTrue { impl ->
val parent = impl.parents().first { it.hasNameEndingWith("UseCase") }
impl.resideInPackage(parent.packagee?.fullyQualifiedName + ".impl")
}
now from what I've understood it should look like this:
Konsist.scopeFromProject()
.classes()
.withParentInterface { it.hasNameEndingWith("UseCase") }
.assertTrue { impl ->
val parent = impl.parentInterfaces().first { it.hasNameEndingWith("UseCase") }
impl.resideInPackage(parent.packagee?.name + ".impl")
}
but those tests are failing now, I've printed some values and it seems that the issue is that the parent's package has wrong value that is inherited from the implementation class
so basically let's say that we have ExampleUseCaseImpl
in com.example.impl
, and the parent interface is named ExampleUseCase
in com.example
, it seems that the parent found with val parent = impl.parentInterfaces().first { it.hasNameEndingWith("UseCase") }
has package name value com.example.impl
instead of com.example
Josef N.
01/13/2025, 10:37 AMassertArchitecture
block supposed to be ok or not?
In arch snippets you have this:
https://docs.konsist.lemonappdev.com/inspiration/snippets/architecture-snippets
presentation.dependsOn(business)
business.dependsOn(presentation)
but in tests it is supposed to throw exception.
Even this specific snippet fails when ran: https://docs.konsist.lemonappdev.com/inspiration/snippets/architecture-snippets#id-1.-2-layer-architecture-has-correct-dependencies
Circular dependency detected: 'Presentation' <-> 'Business'.
I've tried with version 0.17.3Jan Janovec
01/21/2025, 8:42 AMIvan Varga
01/29/2025, 9:22 AMclass MyViewModel(
private val a: A?,
backgroundCoroutineScope: BackgroundCoroutineScope,
) : ViewModel(viewModelScope = backgroundCoroutineScope.scope)
and a Unit test with Konsist:
Konsist.scopeFromProject()
.classes()
.withParentOf(ViewModel::class)
.withName { it.equals("MyViewModel", ignoreCase = true) }
.withPrimaryConstructor()
.properties()
.print()
The print
statement you see above, prints only a
, but not backgroundCoroutineScope
.
I assume this is due to the backgroundCoroutineScope
not being a var nor a val.
Is there a way I can verify that this constructor property exists?
Thank you 🙏Mark Murphy
02/03/2025, 6:50 PMitumeleng
02/17/2025, 3:13 PMdead.fish
02/18/2025, 12:52 PM<component>/konist-checks
modules and this runtime dependency would contain the actual (dynamic) tests. The build convention would also be configurable so that I could change the execution environment of the tests, e.g. by disabling tests that are irrelevant for some components, filtering out legacy Gradle library modules that should not be checked, aso. asf. Would that be a feasible approach or how do people "scale" konsist otherwise?Ali Kabiri
02/26/2025, 10:23 AMMutableSharedFlow
in my code.
An example in simple words: MutableSharedFlow()
is correct, but MutableSharedFlow(replay = 1)
is incorrect.
To test the filtering of non-default calls, I wrote the following code:
val sut = Konsist.scopeFromProject()
.files
.withTextMatching(""".*MutableSharedFlow.*\(.+\)""".toRegex())
println(sut.size)
However, the result of sut.size
is zero, but there are more than 10 occurrences in my files.
I am curious to know if that is the right way to use regular expressions with Konsist because I couldn't find any examples of it in the docs.
Could anyone help me with using regular expressions and Konsist?Berkay Özkan
03/03/2025, 6:57 AMKonsist
.scopeFromProduction()
.files
.forEach {
it.text.isEmpty() shouldBe false
}
rocketraman
03/04/2025, 2:31 PMInvalid package definition for layer 'Core'. To include subpackages, the definition must end with '..'. Current definition: foo.core
. But I don't want to include sub-packages so the declaration should be correct. My full use case is this:
val core = Layer("Core", "foo.core")
val coreApi = Layer("CoreApi", "foo.core.api..")
Konsist.scopeFromProduction()
.assertArchitecture {
core.dependsOn(coreApi)
coreApi.dependsOnNothing()
}
but this test fails because foo.core
is an invalid package definition, and using foo.core..
includes core.api
.David Rubio
03/12/2025, 9:37 PMinternal
. Can this tool do that?Max
03/18/2025, 7:37 PMclass SampleKonsistTest : FreeSpec({
"android activity class name ends with 'Activity'" {
Konsist
.scopeFromProject()
.classes()
.withAllParentsOf(ComponentActivity::class)
.assertTrue { it.name.endsWith("Activity") }
}
})
and dependencies:
testImplementation("com.lemonappdev:konsist:0.17.3")
testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
But when I'm trying to run this test I'm getting the error:
Execution failed for task ':app:testDebugUnitTest'.
> No tests found for given includes: [com.example.polygone.SampleKonsistTest](--tests filter)
Could somebody help me to understand, what I'm doing wrong?Max
04/13/2025, 2:16 PMLayer rootPackage must be unique
rule.
I have many feature-modules in my project, and each feature module divided to api and impl submodules. So I have layers like:
val featureApi = Layer("FeatureApi", "com.example..feature..api.."),
val featureImpl = Layer("FeatureImpl", "com.example..feature..impl..")
I want to check, that my impl modules don't depend on other impl modules.
But I can't just do like this:
featureImpl.doesNotDependOn(featureImpl)
and even
featureImpl.doesNotDependOn(featureImpl.copy(name = "OtherFeatureImpl"))
So, question: Does my case supported in Konsist and how can I make this check?Michał Doliński
05/06/2025, 8:55 PMRasmus Larsen
05/28/2025, 8:52 AM