SalicBlu3
SalicBlu3

Reputation: 1914

Android Studio Mark Directory as Test Sources Root

I've done something in build.gradle to remove the green highlighting of the androidTest.java package.

I don't know how to get it back.

IntelliJ has a "Mark directory as test sources root" option in the context menu but I can't find the equivalent in Android Studio.

Is there a way to define this folder so I can start testing? (If it means anything, the test java files all have an icon of a "J" with a red circle around it)

Upvotes: 16

Views: 10288

Answers (4)

beyondtheteal
beyondtheteal

Reputation: 858

In Android Studio Koala 2023.3.2 Canary 2, if you right-click on the file, at the very bottom of the long menu there is "Mark Directory As".

An image of a popup menu where in the main panel it says "Mark Directory as" and in the second panel there are 6 options - "Sources Root", "Test Sources Root", "Resources Root", "Test Resources Root", "Excluded" and "generated Sources Root" (The icons are Atom Material Icons)

Upvotes: 0

Shamshirsaz.Navid
Shamshirsaz.Navid

Reputation: 2362

For others in case somebody do not use gradle; maybe you can do something like this:

Project Structure > Project Settings:

enter image description here

Upvotes: 0

Michał Powłoka
Michał Powłoka

Reputation: 1511

For me, this option is no longer so easily available. To access it I need to double tap 'shift' and manually type "mark directory as. Then I can pick it from the list."

Upvotes: 1

Diego Villacis
Diego Villacis

Reputation: 588

You can click on the folder and type Cmd + Shift + a to enter the action search and then by typing Mark directory as you will get the menu.

Upvotes: 57

Related Questions