Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I add test folders in Android Studio

I am working on a project in which the test folders were removed and I want to do a unit test. Is there a way to create the test folders again for this project?

like image 980
jeanf Avatar asked May 30 '18 12:05

jeanf


2 Answers

For those who have already created folders with test classes, you can mark its directory as "Test Sources Root". Just click Right-Mouse-Button on the directory, then Mark Directory as/Test Sources Root.

AndroidStudio Test Sources Root

like image 179
Przemo Avatar answered Oct 03 '22 04:10

Przemo


Below are the steps to add your test folders on Android Studio 3.1.2 on Macbook :

  1. Right click on app > New > Folder > Java Folder enter image description here

  2. On Configure Component window check Change Folder Location checkbox enter image description here

  3. Change the location to src/test enter image description here

  4. Your test folder will be created under src folder i.e. same place where previous test folder was

like image 42
Vikasdeep Singh Avatar answered Oct 03 '22 05:10

Vikasdeep Singh