LoginSignup
0
0

More than 5 years have passed since last update.

Kotlin&jUnit4でユニットテストを動かす

Last updated at Posted at 2016-02-28

build.gradle

  • Kotlinでも特別な設定はなし。
    defaultConfig {
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }


dependencies {
    testCompile 'junit:junit:4.12'
    androidTestCompile 'com.android.support.test:testing-support-lib:0.1'
}

AndroidTest

@RunWith(AndroidJUnit4::class)
class MainActivityTest : AndroidTestCase() {

    override fun setUp() {
        super.setUp()
    }

    override fun tearDown() {
        super.tearDown()
    }

    @Test
    fun hoge() {
        Assert.assertEquals("hoge", "hoge")
    }
}

JavaTest

class JavaTest {

    @Before
    fun setUp() {

    }

    @After
    fun tearDown() {

    }

    @Test
    fun hoge() {
        Assert.assertEquals("hoge", "hoge")
    }
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0