1

I have the following project structure:

enter image description here

I want to create tests in the "tests"-folder in the bottom. When I copy-paste a test class inside, it is obviously not recognized, as seen in the image below. How should I make Android Studio recognize the "tests" directory, or something inside it, as a test folder?

enter image description here

Thank you!

Nora
  • 1,825
  • 8
  • 31
  • 47

2 Answers2

0

Since AndroidStudio is IntelliJ based, I think that you should be able to mark your folder as a test folder in the same way you would mark a test folder in IntelliJ (i.e. File->Project Structure->Modules and choosing your given folder as a test folder). See this answer which described it for IntelliJ.

Community
  • 1
  • 1
entpnerd
  • 10,049
  • 8
  • 47
  • 68
0

You should place your tests within the actual modules

This is how the Android + Java Gradle modules work by default.

android
  src 
    main
      java
    test
      java
    androidTest
      java
core
  src
    main
      java
    test 
      java

If you want "integration test", make a new module for that and compile() each module, then still follow that directory structure.

You may find info at Getting Started with Testing

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245