Search code examples
androidandroid-studioandroid-testingandroid-studio-import

Eclipse Android migration to Android Studio lacking the androidTest folder


After migrating a project from Eclipse to Android Studio, I'm unable to locate my androidTest folder which supposed to be generated when I create a new project on Android Studio. Are there any solution to solve it? I'm trying to do TDD yet there is no androidTest folder regardless on what I did. I created a tests folder like how Android Studio create the folder but it is not working.

Hierarchy:

- src
   - main
      - java
      - assets
      - rest
   - test
      - java

Edit: Adding my project structure.


Solution

  • Simply create a test folder in the /src directory of your project and put your tests in there :-) The default was changed to that some time ago.

    Also, in the Build Variants tab (lower left of the IDE window) you need to change the Test Artifact value to "Unit Tests".

    EDIT:

    Try adding this in the android{} section of your build.gradle:

    sourceSets {
        androidTest.setRoot('src/test')
    }