I'm trying to implement testing with JUnit4 in my Kotlin application (as kotlin.test
seems to be nonexistent in my Kotlin Runtime Library, and I don't now how to get it).
However, I am encountering an error simply by using the Test
annotation.
That's my code:
import junit.framework.*
class IntTest {
@Test <------------- This line
fun test1() {
}
}
On the specified line, Eclipse gives an error message: "This class does not have a constructor"
.
I don't understand what is the problem. Which class doesn't have a constructor, and why should it have one?
The junit.framework.Test is an interface and it's implementation has been deprecated since API 24. Since it's an interface hence it is causing the error
"This class does not have a constructor".
during annotation processing which is actually looking for a class.
Solution : Remove this and use import org.junit.Test;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With