Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Unit Testing Robolectric:3.3.2 - No such manifest file: build\intermediates\manifests\full\debug\src\main\AndroidManifest.xml

when i am running my tests, following error is showing

No such manifest file: build\intermediates\bundles\debug\AndroidManifest.xml

java.lang.ClassCastException: android.app.Application cannot be cast to gyg.android.reviews.ReviewApplication

Following are Gradle dependencies

compile group: 'org.mockito', name: 'mockito-all', version: '2.0.2-beta'
testCompile "org.robolectric:robolectric:3.3.2"
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'junit:junit:4.12'

This is how i am starting my Test Class

@RunWith(RobolectricTestRunner.class)
@Config(constants = BuildConfig.class)
public class ReviewListPresenterTest {

I am using Roboelectric 3.3.2 with Android Studio 2.3.2 Quick help will be highly appreciated !

like image 893
Salman Nazir Avatar asked May 15 '17 03:05

Salman Nazir


1 Answers

The problem seems to be with an Android Studio project which contains multiple modules. There are two solutions:

  1. Run the Robolectric tests from the command line:

    gradlew :app:testDebugUnitTest
    
  2. Run the Robolectric tests from Android Studio:

    Open the Edit Run Configurations dialog. Under Defaults > Android JUnit, set the Working Directory to the folder which contains the module you are testing. You will probably also need to set this option for each existing run configuration. If you have tests in multiple modules, you will need to set the Working Directory for each run configuration to the appropriate module.

like image 74
Code-Apprentice Avatar answered Sep 20 '22 11:09

Code-Apprentice