title: Kotlin androidTest: Tests ran to completion. Empty test suite
body: <p>I'm trying to translate my tests from java to kotlin.</p>
  
  <p>Simple unit tests were translated successfully, like this:</p>
  
  <pre><code>class BindingUtilsTest {
    @Test @Throws(Exception::class)
    fun testConvertBooleanToVisibility_visible() {
      assertEquals(BindingUtils.convertBooleanToVisibility(true), View.VISIBLE)
    }
  }
  </code></pre>
  
  <p>But when I'm trying to run androidTest it fails with message: "No tests were found" and </p>
  
  <blockquote>
    <p>Test running started<br>
    Tests ran to completion.</p>
    
    <p>Empty test suite.</p>
  </blockquote>
  
  <p>Code worked perfectly, when was in java. Related code:</p>
  
  <p>build.gradle parts:</p>
  
  <pre><code>apply plugin: "com.android.application"
  apply plugin: "com.neenbedankt.android-apt"
  
  // for tests
  apply plugin: 'kotlin-android'
  
  
  // defaultConfig
  testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
  
  sourceSets {
      test.java.srcDirs += 'src/test/kotlin' // tests are there
      androidTest.java.srcDirs += 'src/androidTest/kotlin' // and there
  }
  
  // unit tests
  testApt "com.google.dagger:dagger-compiler:${daggerVer}"
  
  // kotlin
  testCompile "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVer}"
  testCompile "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}"
  
  // android tests
  
  androidTestApt "com.google.dagger:dagger-compiler:${daggerVer}"
  
  // kotlin
  androidTestCompile "org.jetbrains.kotlin:kotlin-stdlib:${kotlinVer}"
  androidTestCompile "org.jetbrains.kotlin:kotlin-test-junit:${kotlinVer}"
  </code></pre>
  
  <p>Simple test:</p>
  
  <pre><code>@RunWith(AndroidJUnit4::class) class MainDrawerActivityTest {
  
    private val mQuestions = InstrumentationRegistry.getTargetContext().applicationContext as Questions
  
    private val mTestComponentRule = TestComponentRule&lt;Questions, AppComponentTest&gt;(mQuestions,
        DaggerAppComponentTest.builder().appModuleTest(AppModuleTest(mQuestions)).build(),
        { obj, component -&gt; obj.setAppComponent(component) }, // set test component
        { objectToClear -&gt; objectToClear.setAppComponent(null) }) // clear test component
  
    private val mActivityTestRule = ActivityTestRule(
        MainDrawerActivity::class.java, false, false)
  
    // TestComponentRule needs to go first to make sure the Dagger TestComponent is set
    // in the Application before any Activity is launched.
    @Rule @JvmField val mRuleChain: TestRule = RuleChain.outerRule(mTestComponentRule).around(mActivityTestRule)
  
    private var mActivity: MainDrawerActivity? = null
  
    @Before @Throws(Exception::class)
    fun setUp() {
      mActivityTestRule.launchActivity(null)
  
      mActivity = mActivityTestRule.activity
    }
  
    @Test @Throws(Exception::class)
    fun testOnCreate() {
  
      val size = mActivity!!.supportFragmentManager.fragments.size
  
      // check if fragment instantly added
      assertEquals(size.toLong(), 1)
    }
  }
  </code></pre>
  
  <p>Test component is in Kotlin:</p>
  
  <pre><code>// Empty because extends ApplicationComponent
  @Singleton @Component(modules = arrayOf(
      AppModuleTest::class)) interface AppComponentTest : AppComponent
  </code></pre>
  
  <p>And test module is also in Kotlin:</p>
  
  <pre><code>@Module class AppModuleTest(private val mApp: Questions) /*: AppModule*/ {
    @Provides fun provideApp(): Questions {
      return mApp
    }
  }
  </code></pre>
  
  <p>I don't even see, that DaggerAppComponentTest is built.</p>
  
  <p><strong>Why I use apt instead of kapt for tests?</strong></p>
  
  <p>Because I've got an error that I can't mix apt and kapt in one project. I tried to switch apt to kapt and got billion of errors.</p>
  
  <p>As I understand, kapt processes kotlin files and using it people generate kotlin code? And for apt: java files, java code. How to mix it? How to solve this problem?</p>
  
  <p><strong>Solution</strong></p>
  
  <p>Accepted solution works. Before that I returned kapt for Kotlin. With <code>kaptAndroidTest</code> and <code>kaptTest</code>.</p>