I have deleted AndroidTest in my project, but now I need that to test my project, how to create that?
Yes You can delete them ,you can go to build. gradle and then remove following dependencies which comes preloaded in any new android project. and then click on the androidTest and Test package and Press Delete they will be removed !
The AndroidJUnitRunner class is a JUnit test runner that lets you run instrumented JUnit 4 tests on Android devices, including those using the Espresso, UI Automator, and Compose testing frameworks. Note: AndroidJUnitRunner is not needed for local tests.
Open the 'Run...' menu and click 'edit configurations' Click the + button. Select the Android Tests template.
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.
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);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With