我正在经历一些奇怪的行为,涉及到android如何在单元测试中选择Application类。
我在目录src/testDevelopmentDebug中进行了Robolectric单元测试。
我还为单元测试和espresso测试在src/testDevelopmentDebug和androidTestDevelopment之间共享了一些测试代码。共享代码在src/sharedTest中,我的build.gradle文件中有这样的设置:
sourceSets {
// Android Studio / the Android Studio Kotlin Plugin will stop
我正试图为我的android应用程序编写单元和espresso UI测试,用kotlin构建。因为在kotlin中,默认情况下每个类都是最终类,所以为了模拟最终类,我使用了支持模拟最终类的mockInline库。因为我必须同时编写单元测试和UI测试。我以下列方式添加了该库
testImplementation 'org.mockito:mockito-inline:2.13.0'
androidTestImplementation 'org.mockito:mockito-inline:2.13.0'
但是在运行UI测试时,它会抛出
More than one
我有一个EditText元素,允许在其中输入任意文本。输入文本后,用户可以单击next并转到在只读TextView中包含他们编写的文本的活动。
我正在尝试编写一个单元测试,它断言无论用户在第一个活动中写什么,都会正确地传递给第二个活动。我的问题是,当我试图在测试中输入多行文本时,例如
val textToPass = "This is a\nmulti line\nstring."
// or
val textToPass = """
This is a
multi line
string
""".trimIndent()
我断言
有人能解释为什么我在代码下面运行时会出现这个错误吗?获得与其他注释相同的错误(例如@MethodSource,@CsvSource)
class TestRunningOnJUnit5 {
@ParameterizedTest
@CsvSource("test,TEST", "tEst,TEST", "Java,JAVA")
fun toUpperCase_ShouldGenerateTheExpectedUppercaseValue(
input: String,
expected: String?
) {
val a
我有一个应用模块,比方说“测试”。“测试”模块依赖于子模块B。两者都启用了数据绑定。在库模块B中,我使用数据库创建一个简单的活动,它的目的是实现可重用性,例如:我可以创建一个基本登录屏幕,并在以后的许多应用程序中使用它。下面是B包中的示例代码。
package com.test.packageb
open class MainActivity : AppCompatActivity() {
lateinit var binding : ActivityMainBinding
override fun onCreate(savedInstance
我试图使用AndroidStudio4.1Canary10开发一个应用程序,但是每次它抛出构建失败。以下是错误。
任务执行失败:app:generateDebugBuildConfig‘。
E:\example\exampleapp\app\build\generated\source\buildConfig\debug:无法获得文件的详细信息,无法获得文件属性(errno 87)
build.gradle文件
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-a
当我从稳定通道同步Android 4.1.2中的Gradle时,我会收到以下警告:
Failed to resolve: legacy-support-v4-1.0.0
Failed to resolve: asynclayoutinflater-1.0.0
Failed to resolve: media-1.0.0
Failed to resolve: swiperefreshlayout-1.0.0
Failed to resolve: slidingpanelayout-1.0.0
Failed to resolve: legacy-support-core-ui-1.0.0
下面是我
当我尝试运行应用程序时,我得到了以下错误 "java.lang.IllegalStateException: Function not found androidx.compose.internal.restartableFunctionInstance" 以及以下警告: C:\Users\amr\.gradle\caches\transforms-2\files-2.1\29795ea219aedbe5401209deaa0aa414\jetified-kotlin-stdlib-jdk7-1.3.60-eap-25.jar: Runtime JAR file has ve
我是Android的新手。我创建了一个简单的登录活动(刚刚创建),我的项目给出了这个错误:
ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not find any version that matches com.android.support:appcompat-v7:29.+.
我尝试了这些解决方案,但它们不起作用:
https://stackoverflow.com/questions/51218535/unable-to-resolve-dependency-fo
我正在玩预览版的AndroidStudio - 3.4 Canary 9。
我从Configure your project窗口中选择了默认登录活动选项,并提供了以下选项:
在Gradle同步上没有报告错误,但是在构建编译时它会产生以下错误:
Type mismatch: inferred type is LoginActivity but LifecycleOwner was expected
下面是它显示错误的代码片段:
// Type mismatch at this@LoginActivity, required LifeCycleOwner, found - LoginAc