I want to run an Espresso test suit inside APK.
Here is how I have tried
runTest("am instrument -w -m -e debug false -e class 'com.demo.ic.BrightnessTest' com.demo.ic.athens.test/androidx.test.runner.AndroidJUnitRunner")
public String runTest(String command) {
try {
Process process = Runtime.getRuntime().exec(command);
BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
int read;
char[] buffer = new char[4096];
StringBuffer output = new StringBuffer();
while ((read = reader.read(buffer)) > 0) {
output.append(buffer, 0, read);
}
reader.close();
// Waits for the command to finish.
process.waitFor();
return output.toString();
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
Getting below error
TestLoader: Could not find class: 'com.demo.ic.BrightnessTest' java.lang.ClassNotFoundException: Invalid name: 'com.demo.ic.BrightnessTest'
Do I need to define anything to include test case into apk or any other way to do?