Comments (11)
Oh I just noticed in your description "2-After clicking on this button, the app should be restarted (Expected Result)'. You cannot restart the app from within an instrumented test, because that will kill the process the test is running in.
If you need to do this you might want to look into using UiAutomator, and setting up your tests so they run in a different process than the application under test.
from testing-samples.
Can you provide a complete sample and/or a logcat? The list of dependencies look a bit strange with a mixture of very old and new dependencies. eg The ' androidTestImplementation 'com.android.support.test:rules:1.0.2'' especially seems wrong
from testing-samples.
Can you provide a complete sample and/or a logcat? The list of dependencies look a bit strange with a mixture of very old and new dependencies. eg The ' androidTestImplementation 'com.android.support.test:rules:1.0.2'' especially seems wrong
This is the complete very simple test case
and no problem with ' androidTestImplementation 'com.android.support.test:rules:1.0.2'' especially seems wrong
i remove it and the same error happen
@RunWith(AndroidJUnit4.class)
public class SplashActivityTest{
@Rule
public ActivityScenarioRule<SplashActivity> mActivityScenarioRule =
new ActivityScenarioRule<>(SplashActivity.class);
@Test
public void splashActivityTest(){
onView(withId(R.id.preliveButton)).perform(click());
from testing-samples.
Sorry but without a full sample or logcat our ability to help is going to be limited. I tried copying over your list of dependencies into a simple sample project and it worked fine. You can use one of http://github/android/testing-samples as a base
from testing-samples.
Collaborator
but this is a hard restart, this button should be clicked at the start of the process to can select the environment
and after clicking, the app will hard restart.
so can't handle this case with espresso?
from testing-samples.
Oh I just noticed in your description "2-After clicking on this button, the app should be restarted (Expected Result)'. You cannot restart the app from within an instrumented test, because that will kill the process the test is running in.
If you need to do this you might want to look into using UiAutomator, and setting up your tests so they run in a different process than the application under test.
and how can i use UiAutomator to can continue my test cases after restarting app?
from testing-samples.
Espresso will wait for the app to be idle after the click is sent, so I strongly suspect this case cannot be handled in espresso. How does the code under test restart the app?
For UiAutomator, check out https://github.com/android/testing-samples/tree/main/ui/uiautomator/BasicSample. You'll likely need to adjust the targetProcess here
from testing-samples.
Espresso will wait for the app to be idle after the click is sent, so I strongly suspect this case cannot be handled in espresso. How does the code under test restart the app?
For UiAutomator, check out https://github.com/android/testing-samples/tree/main/ui/uiautomator/BasicSample. You'll likely need to adjust the targetProcess here
to com.example.android.testing.uiautomator.BasicSample.test and perhaps make other changes
The screen asks you to choose the required data then the app restarts with the data you choose before.
Intent i = activity.getBaseContext().getPackageManager().getLaunchIntentForPackage(activity.getBaseContext().getPackageName());
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
activity.startActivity(i);
activity.finishAffinity();
System.exit(0);
```
> and i will check uiautomator, Thanks
from testing-samples.
Yeah there isn't a way to handle a System.exit(0) from an instrumentation test that runs in the same process
from testing-samples.
Yeah there isn't a way to handle a System.exit(0) from an instrumentation test that runs in the same process
yea I tried UI Automator and instrumentation crushed also, so is there any way to handle this case?
from testing-samples.
Did you configure the UI Automator instrumentation to run in a different process than the app under test? See the manifest link I gave above
from testing-samples.
Related Issues (20)
- Blind Helpet
- Ali HOT 1
- Basic sample(in Kotlin) for writing unit tests that mock the Android Framework sample App build is failing HOT 1
- Bébé HOT 1
- Cannot run tests with Android Test Orchestrator using `adb` HOT 2
- Could not resolve com.android.tools.utp:android-test-plugin-host-additional-test-output:30.3.1 HOT 1
- `captureToBitmap` clips the image to the device screen size HOT 1
- testInstrumentationRunnerArguments clearPackageData in kotlin dsl and recent gradle HOT 1
- Support test validation on GitHub Actions HOT 2
- instrumentation app can use proguard?
- A
- Test HOT 1
- A HOT 1
- Run HOT 1
- Test HOT 1
- A
- Aa
- A
- My sample
- ScreenshotTestSample with Gradle Manged Devices and several shards generates screenshots for last shard only
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
đ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. đđđ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google â€ïž Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from testing-samples.