Why are RectF objects empty in UnitTests

Viewed 64

Project:
I'm developing an Android application that matches MotionEvents to Rectangles which I defined using the RectF class.

Issue:
In my UnitTests these RectF objects are empty. The debugger describes them as "null" and left,top,right,bottom are 0.0

My guess:
I guess AndroidStudio replaces the RectF with some empty mock (as it apparently does with other code as well). I can't verify it in another IDE currently.

UnitTest code:

import android.graphics.RectF
import junit.framework.TestCase
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.core.Is.`is`
import org.junit.Test

class RectTest: TestCase() {
    @Test
    fun test() {
        val rectF = RectF( -10.0F, -30F, 10F, 50F )
        assertThat( rectF.width(), `is`( 20F ) )
    }
}

Note that the test class is in src/test not in src/androidTest.

0 Answers
Related