Android Studio Mark Directory as Test Sources Root
Asked Answered
R

4

16

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)

Rebec answered 31/7, 2015 at 14:33 Comment(2)
If it's not available in the right-click menu of the project view, then it should be available in the Project Settings. Have you looked there?Laggard
You should mark Diego's answer as correct, I tried it and it works perfectlyKyliekylila
I
57

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.

Iceskate answered 3/10, 2016 at 22:17 Comment(0)
E
1

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."

Engraving answered 14/10, 2019 at 15:6 Comment(1)
Actually this is easily available: it is offered in the context menu of folders (right click).Insalubrious
C
0

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

Project Structure > Project Settings:

enter image description here

Childers answered 4/12, 2021 at 18:18 Comment(0)
E
0

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)

Eurhythmic answered 7/5 at 4:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.