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

Klitos Kyriacou

03/10/2022, 10:38 AM
What is the latest preferred way of dealing with JaCoCo and
@Serializable
classes? I see several StackOverflow questions and answers that are 3+ years old, and there is a still outstanding issue 961. Has anyone solved the problem satisfactorily?
m

Matthias Geisler

03/10/2022, 10:52 AM
You can simply exclude them in Jacoco.
k

Klitos Kyriacou

03/10/2022, 11:11 AM
That is what I'm doing right now, but it's only a workaround. For example, if I add a member function to a serializable class, it would be nice to have it coverage-checked, but it won't be if I exclude the class.
m

Matthias Geisler

03/10/2022, 11:37 AM
I think this is not possible...to have such an behaviour you need to tap into Jacoco I suppose. Such behaviour would require selective probing during runtime or while generating the coverage report. However it sounds like you are combining behaviour and state which gets serialised...can you not just pull out the state in separate thing?
t

Tim Oltjenbruns

03/10/2022, 1:58 PM
However it sounds like you are combining behaviour and state which gets serialised...can you not just pull out the state in separate thing?
This sounds desirable to me, if its an option
At the very least could you use an extension function? That should be checked for coverage.
m

Matthias Geisler

03/10/2022, 2:09 PM
Good question...how Lombok does it...I believe to remember they ship around that...
k

Klitos Kyriacou

03/10/2022, 2:15 PM
Thanks, an extension function sounds like a good idea.
266 Views