Reputation: 77
I have deleted AndroidTest in my project, but now I need that to test my project, how to create that?
Upvotes: 5
Views: 4937
Reputation: 1253
If your androidTest package has been deleted/not being shown, then do the following:
The best and easy way is to open your Android project in File Explorer (My Computer/Windows explorer in Windows OS )
Then go to app-->src
(There you will already find your main folder)
Now, create a new package/folder in app-->src and name it as androidTest
NOTE: the name is case sensitive. Type as shown above.
Now in you app-->src-->main folder, copy the java folder and paste it in app-->src-->androidTest folder.
Now in androidTest folder, open all the folder inside till the end and delete the existing java files.
Now in your Android Studio, you can clearly see the folder/package of androidTest made. Just add new Java file and write all the test code stuff there and its done.
Upvotes: 7
Reputation: 4025
Just add a new java file in {root project dir}/app/src/androidTest/java/com/company/name
Android Studio will recognize it as AndroidTest.
package com.company.name;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
Upvotes: 5