Show android emulators when running tests via gradle managed devices - android

When running android espresso tests via gradle managed devices, i.e. by running:
./gradlew pixel4api30DebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.aaa.bbb.ccc.Suites.TestSuite -Pandroid.experimental.androidTest.numManagedDeviceShards=3
Is it possible to have it display the emulators while running the tests so that you are able to see what is happening?

You can use the --enable-display switch:
./gradlew pixel4api30DebugAndroidTest --enable-display
But keep in mind that this will not work with ATD images.

Related

Android Studio 3.2 empty test suite

I have created a new project in Android Studio 3.2. Without making any changes I am not able to run all the unit tests in the group. I receive and error saying No tests were found
I am attempting to run the tests by right clicking on the group and clicking Run Tests.
I can run the unit tests if I open up the file and click on the run button next to the class declaration. I can also run the unit tests if I open the project in Android Studio 3.1.4. I can right click on the group and run all the unit tests with no error.
Looking at this bug report, I think it should be fixed in 3.2.1: https://issuetracker.google.com/issues/115708445#comment12
After spending an entire day trying resolve this while writing some unit tests I found one workaround that works for my project.
Basically what my workaround is to add Build to the Before launch options.
After adding this option I'll occasionally get the No tests found error message but simply rerunning the test worked every time after adding that setting.
I'm not sure if it will help with everyone's problem but it seems to have mitigated the issue with my project. Hopefully this works for someone else as well.
The workaround until the bug is fixed is running tests in terminal, just type:
./gradlew test
or
./gradlew testDebugUnitTest. If you are using Windows replace ./gradlew with gradlew.bat. You can also download Android Studio 3.3 Canary from here https://developer.android.com/studio/preview/ – there aren't problems with running tests via this version.

Android Unit tests running forever in android studio

For whatever reason the unit tests in Android Studio will not stop running despite hitting the stop button multiple times.
I've tried ./gradlew --stop in the terminal already, and I've also checked Android Instrumentation Tests Stuck "Running Tests" Forever Android Studio, as well as well as Gradle Build too long, but they did not solve my problem.
If someone can please help me I will greatly appreciate it. Thanks!
Picture of android Studio screen showing the running processes in the top right

connectedAndroidTest task runs all test even when class is specified

I m trying to run instrumented unit tests using connectedAndroidTest. At first I jus wanted run to particular class using cAT. So I tried below command
./gradlew app:connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.company.test.data.model.TestClassName
but it runs all the tests including the robotium and espresso tests which were written. I gone through lots of StackOverFlow posts, in all posts the answer is the above specified command.
when I tried
adb shell am instrument -e class com.company.test.data.model.TestClassName com.company.test/android.support.test.runner.AndroidJUnitRunner
It ran the tests as expected. The problem is I wont get jUnit Reports by the adb command but cAT will provide me test reports, code coverage reports as required.
Does anyone have solution for this issue to run specific tests?
It was actually the problem with gradle version. The developers had set the gradle version to 2.3 in which I was facing the issue. Then I have updated the gradle version to 2.10 and the issue is fixed.

Running multiple test with connectedCheck using Espresso

I am using Espresso. I have multiple tests written, all in different classes but the same project. When I run I remove all but one class and try running, it runs fine. However, when I have them all in my project and try running the second one always fails.
All of my test are pretty basic right now. They just have setUp() and one testMethod().
Can someone tell me what I am doing wrong?
NOTE: I run via terminal with command gradle appName:cC
I found my answer. I need to add the Spoon Gradle Plugin
That's one option, but you don't have to, you can still use gradle command connectedCheck
Find out how to run the tests (including running tests for a specific module and on multiple devices) here at this Google example:
https://github.com/googlesamples/android-testing-templates/tree/master/AndroidTestingBlueprint

Android: Deploy Test Project

I've created a Test project in eclipse to run some tests for one of my android library. I can run it without problems in eclipse on my device. Is it possible to run these tests on other devices without having them connected to eclipse? I want to send the test project apk to other people so they can run the tests on their device.
I think I'd need something like a test runner app that runs the test and displays the result on the device itself. Does anyone know such an app?
Thanks
Is it possible to run these tests on other devices
without having them connected to eclipse?
yes it is!!
just send the tested .apk file to their mobile, install and use app.
no need any test runner app for this, i have checked it.

Categories

Resources