vendredi 21 septembre 2018

How do I get test coverage for Kotlin's class with only static constants (companion object consts)

I have a class in Kotlin with only static constants, a class with companion object containing only const val as we call it in Kotlin. It looks something like this..

package com.abc.xyz.util

class Constants {
    companion object {
        const val DEFAULT_VAL = 0
        const val USERNAME_FOR_ABC = "*"
    }
}

I wrote a method with just Assert.assertEquals like Assert.assertEquals(Constants.DEFAULT_VAL, 0) & Assert.assertEquals(Constants.USERNAME_FOR_ABC, "*") but it did not increase the test case coverage.

I want to know if there is a way I can cover this class under testing and increase my test coverage?

Aucun commentaire:

Enregistrer un commentaire