https://kotlinlang.org logo
#code-coverage
Title
# code-coverage
s

Shervin

03/04/2024, 4:58 PM
Hey everyone, While running code coverage I see all lines of a Kotlin sealed
object
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?
k

Klitos Kyriacou

03/04/2024, 5:27 PM
What do you mean by "sealed object"?
s

Shervin

03/04/2024, 5:27 PM
Scratch that
Object Person {
Data class Me(…)
}
I hVe test for Me But Person is not covered
k

Klitos Kyriacou

03/04/2024, 5:33 PM
The
data class Me
is just enclosed in
object Person
but it's not actually part of the object. It's not an inner class, but just a nested class. Thus, when you test
<http://Person.Me|Person.Me>
you're simply using
Person
as a namespace. To actually test
Person
, you need to check a property of the object.
s

Shervin

03/04/2024, 5:35 PM
Yeah The Person object is more of a place where we aggregate component related to that. They can leave outside of Person but I think having that makes it easier to access the content from other class by typing Person. Bla bla
k

Klitos Kyriacou

03/04/2024, 5:36 PM
There is a new feature request being considered, to introduce namespaces to Kotlin. That might be the answer you're looking for.
c

CLOVIS

03/04/2024, 8:22 PM
The feature request in question: https://github.com/Kotlin/KEEP/issues/348
s

Shervin

03/04/2024, 8:25 PM
yeah! that is what I need!