Questions tagged [robolectric-gradle-plugin]

The robolectric-gradle-plugin is a plugin for Gradle that allows Android Gradle builds to run Robolectric style tests.

The robolectric-gradle-plugin is a plugin for Gradle that allows Android Gradle builds to run Robolectric style tests.

It was originally authored by Jake Wharton and is available from Maven central.

77 questions
6
votes
3 answers

Cannot add a configuration with name 'testCompile' as a configuration with that name already exists

When updating to gradle plugin 1.1.0 I kept getting the following error Cannot add a configuration with name 'testCompile' as a configuration with that name already exists I am also using the Robolectric gradle plugin from here, v0.14.0. The new…
6
votes
6 answers

Manifest and setup issues getting Robolectric working with Android Studio 1.1.0

I am trying to get Robolectric tests up and working in our current project, and not having a lot of luck. My preference would be to get these to run within Android Studio 1.1.0+. This is my project structure: and here is my test: import…
TheIcemanCometh
  • 1,055
  • 2
  • 17
  • 31
5
votes
1 answer

Android - Testing a string resource with Robolectric

I just want to test that getting a String resource equals what I think it should equal. My issue seems to be that I have Realm in my project. I know that Robolectric doesn't support Realm (it states it in the documentation), but I'm not invoking…
EGHDK
  • 17,818
  • 45
  • 129
  • 204
5
votes
0 answers

Robolectric filenotFound on asset files

Hi i am using robolectric version 3.0 for unit testing my app and have the asssets folder with some files inside under src/test/assets but keep getting fileNotFound. Here is my test…
Jono
  • 17,341
  • 48
  • 135
  • 217
5
votes
3 answers

Android java.lang.NoClassDefFoundError: R$string

whenever i run a unit test, i get this error when it tries to retrieve a string value from a custom config.xml file. Background: The project itself is a library apk project that uses and references another library APK project. The error occurs when…
Jono
  • 17,341
  • 48
  • 135
  • 217
5
votes
1 answer

Robolectric 2.4 NoSuchMethodError cannot be cast to RuntimeException when creating activity

I am starting to use Robolectric in Android Studio. At first I wanted to create a simple test using hamcrest, which is shown below: @RunWith(CustomTestRunner.class) @Config(emulateSdk = 18) public class MainActivityTest { private MainActivity…
5
votes
3 answers

How can I ignore test failures with the gradle robolectric plugin?

I'm using the robolectric-gradle-plugin for robolectric unit tests. I don't want to fail a build on failed tests. Is there a way in DSL or a property not to fail a test on the build similar to -DtestFailureIgnore=true on the Surefire Maven…
C. Ross
  • 31,137
  • 42
  • 147
  • 238
4
votes
2 answers

Robolectric with test.R.java

I've got a library project using robolectric 3.0 at API21, with com.android.tools.build:gradle:1.3.1. I want to use test resources (as if under src/androidTest/res/...), namely com.mypackage.test.R.java (as opposed to com.mypackage.R.java for…
4
votes
1 answer

Gradle Build Test "Could not normalize...", for doing Robolectric tests in Android Studio

Running gradlew test --stacktrace on Windows 8.1. I'm getting this error: Could not normalize path for file…
3
votes
1 answer

android studio robolectric test no coverage

First off, I know that this question appears to be a duplicate. However, none of the other questions are recent enough to still work. I've tried it. The problem is as follows: when using the internal "Run with coverage" functionality of Android…
3
votes
1 answer

The SourceSet 'robolectric' is not recognized by the Android Gradle Plugin

Updated to Android Studio 3.1 and its corresponding gradle. I'm getting a message when trying to sync "The SourceSet 'robolectric' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?". Here is the current sourceSet in…
3
votes
0 answers

Robolectric activity test which usage Custom View throw java.lang.ClassNotFoundException:

My activity xml contains customeView (TitleToolbar). When I run my unit test, robolectric failed during onCreate method of my Activity creation. The exception details says that it failed to create customeView(TitleToolbar) and throws "Error…
3
votes
2 answers

Robolectric with Google APIs - AnnotationFormatError

I tried to setup robolectric to work with my project compiled against a Google API target, but can't get it to work. I have tried various approaches and have isolated the problem using deckard-gradle: When I download the deckard project everything…
ct_rob
  • 521
  • 3
  • 16
3
votes
1 answer

Testing an Activitys WebView using Robolectric, not loading page

I'm trying to test out some content in a WebView using Robolectric, however there is no data coming into it. I have called the following before loadUrl() on the…
3
votes
1 answer

How to run unit tests with IDEA+Gradle+Android

I've written some unit tests in my Android projects with Robolectric, and some of them even don't use Android. I've tried first this: robolectric-gradle-plugin, following this template. The result is that I've faced this bug in IDEA, that I reported…