Skip to content

Commit

Permalink
Merge pull request #9 from OJZen/develop
Browse files Browse the repository at this point in the history
修复在执行Android测试时找不到 string.xml 的问题
  • Loading branch information
1250422131 authored Jul 1, 2023
2 parents 8dbff9b + 8f30f49 commit ca10507
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.imcys.bilibilias

import android.util.Log
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.imcys.bilibilias.base.app.App
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith
Expand All @@ -13,10 +15,30 @@ import org.junit.runner.RunWith
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
companion object{
var TAG = "ExampleInstrumentedTest"
}

@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.imcys.bilibilias", appContext.packageName)
}

@Test
fun outputJson(){
val appContext = InstrumentationRegistry.getInstrumentation().targetContext

val videoIndex: String by lazy {
appContext.getString(R.string.VideoIndex)
}

val bangumiEntry: String by lazy {
appContext.getString(R.string.BangumiEntry)
}

Log.d(TAG, videoIndex)
Log.d(TAG, bangumiEntry)
}
}
7 changes: 7 additions & 0 deletions app/src/androidTest/res/values/string.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name_debug" translatable="false">BILIBILIAS_DEBUG</string>
<string name="app_name_release" translatable="false">BILIBILIAS</string>
<string name="app_channel_release" translatable="false">Official Channel</string>
<string name="app_channel_debug" translatable="false">Official Channel Debug</string>
</resources>

0 comments on commit ca10507

Please sign in to comment.