No tests found for given includes Error, when running Parameterized Unit test in Android Studio

前端 未结 17 2370
孤独总比滥情好
孤独总比滥情好 2021-01-31 07:03

I tried run Parameterized Unit Test as below in Android Studio.

import android.test.suitebuilder.annotation.SmallTest;  

import junit.framework.TestCase;    

i         


        
17条回答
  •  感动是毒
    2021-01-31 07:13

    I made the mistake of defining my test like this

    class MyTest {
        @Test
        fun `test name`() = runBlocking {
    
    
            // something here that isn't Unit
        }
    }
    

    That resulted in runBlocking returning something, which meant that the method wasn't void and junit didn't recognize it as a test. That was pretty lame. I explicitly supply a type parameter now to run blocking. It won't stop the pain or get me my two hours back but it will make sure this doesn't happen again.

    class MyTest {
        @Test
        fun `test name`() = runBlocking { // Specify Unit
    
    
            // something here that isn't Unit
        }
    }
    

提交回复
热议问题