package io.github.droidkaigi.confsched2017.util

import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import java.lang.reflect.InvocationTargetException

@RunWith(RobolectricTestRunner::class)
class AssetsUtilTest {
    @Test
    @Throws(Exception::class)
    fun ctor() {
        try {
            val ctor = AssetsUtil::class.java.getDeclaredConstructor()
            ctor.isAccessible = true
            ctor.newInstance()
        } catch (e: InvocationTargetException) {
            if (e.cause !is AssertionError)
                fail()
        }
    }
}

package io.github.droidkaigi.confsched2017.util

import com.google.firebase.FirebaseApp
import com.taroid.knit.should
import org.junit.Assert.fail
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import java.lang.reflect.InvocationTargetException

@RunWith(RobolectricTestRunner::class)
class AssetsUtilTest {
    @Test
    @Throws(Exception::class)
    fun ctor() {
        try {
            val ctor = AssetsUtil::class.java.getDeclaredConstructor()
            ctor.isAccessible = true
            ctor.newInstance()
        } catch (e: InvocationTargetException) {
            if (e.cause !is AssertionError)
                fail()
        }
    }

    @Test
    @Throws(Exception::class)
    fun loadJSONFromAsset_succseedsWhenFileExists() {
        val context = RuntimeEnvironment.application
        context.assets.list("json").forEach {
            val expect = context.assets.open("json/" + it)
                                       .reader(charset = Charsets.UTF_8)
                                       .use { it.readText() }
            val actual = AssetsUtil.loadJSONFromAsset(context, it)

            actual.should be expect
        }
    }

    @Test
    @Throws(Exception::class)
    fun loadJSONFromAsset_failsWhenFileNotExists() {
        FirebaseApp.initializeApp(RuntimeEnvironment.application)
        AssetsUtil.loadJSONFromAsset(RuntimeEnvironment.application, "NonExistsFile.json").should be null
    }
}

Add succeed and fail tests
Add succeed and fail tests


futabooo/conference-app-2017,ogapants/conference-app-2017,hironytic/conference-app-2017,kaelaela/conference-app-2017,wakwak3125/conference-app-2017,kgmyshin/conference-app-2017,futabooo/conference-app-2017,k-kagurazaka/conference-app-2017,chibatching/conference-app-2017,u-nation/conference-app-2017,kikuchy/conference-app-2017,k-kagurazaka/conference-app-2017,chibatching/conference-app-2017,DroidKaigi/conference-app-2017,k-kagurazaka/conference-app-2017,shaunkawano/conference-app-2017,sys1yagi/conference-app-2017,ogapants/conference-app-2017,kobakei/conference-app-2017,futabooo/conference-app-2017,u-nation/conference-app-2017,kobakei/conference-app-2017,u-nation/conference-app-2017,hironytic/conference-app-2017,kgmyshin/conference-app-2017,eyedol/conference-app-2017,kitwtnb/conference-app-2017,sys1yagi/conference-app-2017,ogapants/conference-app-2017,hironytic/conference-app-2017,kobakei/conference-app-2017,u-nation/conference-app-2017,shaunkawano/conference-app-2017,kaelaela/conference-app-2017,horie1024/conference-app-2017,sys1yagi/conference-app-2017,kaelaela/conference-app-2017,kitwtnb/conference-app-2017,DroidKaigi/conference-app-2017,kgmyshin/conference-app-2017,kikuchy/conference-app-2017,kitwtnb/conference-app-2017,DroidKaigi/conference-app-2017,ogapants/conference-app-2017,kobakei/conference-app-2017,k-kagurazaka/conference-app-2017,DroidKaigi/conference-app-2017,kobakei/conference-app-2017,kitwtnb/conference-app-2017,kaelaela/conference-app-2017,shaunkawano/conference-app-2017,wakwak3125/conference-app-2017,chibatching/conference-app-2017,eyedol/conference-app-2017,shaunkawano/conference-app-2017,kikuchy/conference-app-2017,wakwak3125/conference-app-2017,ogapants/conference-app-2017,horie1024/conference-app-2017,sys1yagi/conference-app-2017,futabooo/conference-app-2017,k-kagurazaka/conference-app-2017,kikuchy/conference-app-2017,DroidKaigi/conference-app-2017,hironytic/conference-app-2017,wakwak3125/conference-app-2017,hironytic/conference-app-2017,futabooo/conference-app-2017,wakwak3125/conference-app-2017,chibatching/conference-app-2017,chibatching/conference-app-2017,sys1yagi/conference-app-2017,eyedol/conference-app-2017,u-nation/conference-app-2017,eyedol/conference-app-2017,kgmyshin/conference-app-2017,kaelaela/conference-app-2017,horie1024/conference-app-2017,eyedol/conference-app-2017,kitwtnb/conference-app-2017,horie1024/conference-app-2017,kgmyshin/conference-app-2017,horie1024/conference-app-2017,shaunkawano/conference-app-2017,kikuchy/conference-app-2017