小编Rob*_*iro的帖子

Android Studio中无法识别"RobolectricTestRunner.class"

我正在尝试使用Robolectric来运行单元测试,但Android Studio无法识别该类:

@RunWith(RobolectricTestRunner.class)
Run Code Online (Sandbox Code Playgroud)

细节:

classpath 'com.android.tools.build:gradle:3.0.0'
Run Code Online (Sandbox Code Playgroud)

我正在导入依赖:

testImplementation "org.robolectric:robolectric:3.5.1"
Run Code Online (Sandbox Code Playgroud)

和:

android {
    testOptions {
        unitTests {
            includeAndroidResources = true
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

它似乎没有出现导入类的选项.我应该添加任何我忘记的依赖项吗?

错误:

 error: package org.robolectric does not exist
 error: package org.robolectric does not exist
 error: package org.robolectric.shadows does not exist
 error: cannot find symbol class RobolectricTestRunner
 error: cannot find symbol variable Robolectric
 error: cannot find symbol variable ShadowApplication
Run Code Online (Sandbox Code Playgroud)

android unit-testing robolectric android-gradle-plugin robolectric-gradle-plugin

11
推荐指数
4
解决办法
2701
查看次数

NavigationView窗格背景

如何更改NavigationView窗格背景?

我正在尝试这种方式:

<NavigationView.Background>
   <LinearGradientBrush EndPoint="0.5,0" StartPoint="0.5,1">
      <GradientStop Color="#b1c899" Offset="0"/>
      <GradientStop Color="#18c1b9" Offset="1"/>
   </LinearGradientBrush>
</NavigationView.Background>
Run Code Online (Sandbox Code Playgroud)

但它似乎有" acrylic我无法删除,以及改变背景颜色Header.

windows pane navigationview uwp

8
推荐指数
1
解决办法
2516
查看次数

使用 Espresso 检查 EditText 的字体大小、高度和宽度

如何使用 Espresso 检查 EditText 的字体大小、高度和宽度?

目前我使用的文本是:

onView(withId(R.id.editText1)).perform(clearText(), typeText("Amr"));

并阅读文本:

onView(withId(R.id.editText1)).check(matches(withText("Amr")));
Run Code Online (Sandbox Code Playgroud)

android android-edittext android-espresso

7
推荐指数
1
解决办法
2326
查看次数

使用“hasTextColor”使用浓缩咖啡进行测试

如何使用文本颜色进行浓缩咖啡测试?目前使用hasTextColor()

onView(withId(R.id.editText)).check(matches(hasTextColor(Color.BLACK)));
Run Code Online (Sandbox Code Playgroud)

但出现错误:

android.content.res.Resources$NotFoundException:资源 ID #0xff000000 在 android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:195)

...

细节:

<EditText
 android:id="@+id/editText"
 android:textColor="#ff000000"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:layout_marginTop="48dp"/>
Run Code Online (Sandbox Code Playgroud)

android textcolor android-edittext android-espresso

6
推荐指数
1
解决办法
1585
查看次数

运行选项:--seed 16186

当我执行ruby -Itest test/models/usuario_test.rb迷你测试时显示消息:

运行选项:--seed 16186

我想删除该消息,但这不是一个严重的错误,它只是一个演示改进。

谢谢现在!

ruby-on-rails minitest

6
推荐指数
0
解决办法
583
查看次数

Robolectric: “AndroidManifest.xml not found” and "Unable to find resource ID #0x7f09001b"

I'm running some tests with Roboletric, but I came across a issue that I can't solve. When I run the test, the following error appears with the "AndroidManifest":

WARNING: No manifest file found at .\AndroidManifest.xml.

Falling back to the Android OS resources only. To remove this warning, annotate your test class with @Config(manifest=Config.NONE).

No such manifest file: .\AndroidManifest.xml

I've tried these solutions that failed:

@Config (manifest = Config.DEFAULT_MANIFEST_NAME)

@Config(manifest = Config.NONE, constants = BuildConfig.class, sdk = 26)

@Config( constants …
Run Code Online (Sandbox Code Playgroud)

android compiler-errors android-manifest robolectric

1
推荐指数
1
解决办法
994
查看次数

无法在包 [android, org.robolectric.default] 中找到资源 ID #0x7f09001c

我正在使用 Roboletric 运行一些测试,但遇到了一个我无法解决的问题。当我运行测试时,出现以下错误:

android.content.res.Resources$NotFoundException:无法在包 [android, org.robolectric.default] 中找到资源 ID #0x7f09001c

在 org.robolectric.shadows.ShadowAssetManager.getResName(ShadowAssetManager.java:925)

在 org.robolectric.shadows.ShadowAssetManager.loadXmlResourceParser(ShadowAssetManager.java:439)

在 org.robolectric.shadows.ShadowResources.loadXmlResourceParser(ShadowResources.java:221)

在 android.content.res.Resources.loadXmlResourceParser(Resources.java)

在 android.content.res.Resources.getLayout(Resources.java:852)

在 android.view.LayoutInflater.inflate(LayoutInflater.java:394)

在 android.view.LayoutInflater.inflate(LayoutInflater.java:352)

在 com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:256)

在 android.app.Activity.setContentView(Activity.java:1867)

在 com.example.robertoassad.roboletrictest.MainActivity.onCreate(MainActivity.java:15)

在 android.app.Activity.performCreate(Activity.java:5008)

在 org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:232)

在 org.robolectric.android.controller.ActivityController$1.run(ActivityController.java:58)

在 org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:364)

在 org.robolectric.shadows.CoreShadowsAdapter$1.runPaused(CoreShadowsAdapter.java:26)

在 org.robolectric.android.controller.ActivityController.create(ActivityController.java:55)

在 org.robolectric.android.controller.ActivityController.create(ActivityController.java:65)

在 org.robolectric.android.controller.ActivityController.setup(ActivityController.java:157)

在 org.robolectric.Robolectric.setupActivity(Robolectric.java:101)

在 com.example.robertoassad.roboletrictest.MainActivityTest.clickingLogin_shouldStartLoginActivity(MainActivityTest.java:20)

在 org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

在 org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)

在 org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)

在 org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)

在 org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:523)

在 org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:226)

在 org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:108)

在 org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:35)

在 org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)

在 org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)

在 org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)

在 org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)

在 org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)

在 org.robolectric.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:62)

在 org.junit.runners.ParentRunner.run(ParentRunner.java:363)

在 …

junit android unit-testing robolectric android-activity

1
推荐指数
1
解决办法
2201
查看次数