Android gradle connectedCheck resume on failure - android

Is it possible to resume on failure, while running gradle connectedCheck?
I want to use it in hudson, but it stopped execution after the first failure. How can I configure it to do the next test on failure? This way, I see all failing tests at the end and not only the first one.

This may not answer the question in the way you wanted but here goes anyway. What I did to solve this problem was to use the Spoon testing framework as a wrapper around the Android test framework. It gives you lots of advantages:
You can use the regular tests you've already created
Spoon produces permanent HTML output that you can save
You can add screenshots to your test output
The test output contains the log messages for failures
And, most relevant to your question, it continues on even when a test fails.
You can find spoon at: http://square.github.io/spoon/

Related

Android instrumentation does not start on a second device

Since some time, when I run an instrumentation test on a device (emulator) and try to start another test on a second device in parallel, I get the following exception:
FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':app:connectedDebugAndroidTest'.
java.nio.file.FileSystemException: D:\Android\MyApp\app\build\outputs\androidTest-results\connected\name_of_the_first_device\logcat-MyApp.TestClassName-TestName.txt:
The process cannot access the file because it is being used by another process
The problem seems to be, that the build process tries to access a file from the first test device, which is already blocked. But I'm using a different device and try to run a different test.
The reason why I do that is because some of the tests are very large and therefore I try to spread them to several devices, so I get my results faster. The machine I run the tests on, has a hell of performance, so it can't be a problem of the resources ;-).
When I did the described actions some months ago, it worked properly, so I guess it's due to some updates (probably in Gradle or whatever). But I installed several updates since then, so it can't just be a problem of the current version.
Update - Two more inputs:
I recently switcht to using hilt and therefore created my own TestRunner, because an Application annotated with #HiltApplication cannot be used for tests, so I had to create a custom one for testing which needs to be run in a custom TestRunner as described here.
When I run the same tests on multiple devices using "Select Multiple Devices" dropdown in Android Studio it works properly.
The error message indicates a conflict over a build-and-run output file on your development computer, not on the Android test device. That is, it's trying to do another build-and-run in the same build output directory that the running test is using for purposes like the test's logcat output.
My first thought is to try duplicating androidTest to another build target. Same contents, different target name, different output directory. That workaround seems likely to get past this limitation (but with new limitations) and to help debug the problem. But the name_of_the_first_device subdirectory suggests that it can keep a logcat output file per test device, so the real question is how to get the test runner to use a separate subdirectory per test device.
Second thought is to point you to the the docs, Run Tests with Multiple Devices and Shard Tests.
With a custom TestRunner, see Write a Sharded IRemoteTest Test Runner (and other pages in the "Tradefed" section) on making it a "shardable" test runner which enables the test infrastructure to distribute the full test execution over several devices.

See logs when AndroidStudio is stuck on Gradle: Build

How to understand what and why really happens behind Gradle: Build? There is no console or crashes, just endless building. Maybe there is network issue which happens again and again, but how can developer know it?
This is a sample of just new project:
From terminal everything works fine. So the question is not about how to solve particular problem, but more about generic solution when IDE doesn't show anything except "progress".
You can execute ./gradlew build manually in the terminal to see its logs. You can also add --debug or --stacktraceparameter to enable verbose logging.
I have a similar answer to Andre, but with a suggestion of some potential culprits.
If an issue is happening, Android Studio is just a GUI wrapper on the terminal. So just run the commands and see what the hold up or error is.
However, Often times when I see freezing up that takes a long time to fail it is network related items. Such as an internal Maven repo that is not resolving properly. So check your internal Maven repos as well that they exist and you set them up correctly.
You can also turn off the internet and start it up, it will load into offline mode and not attempt to load any internet items and offers popup to move to offline mode in gradle. This will give you a chance to make your corrections until Android Studio improves these issues.
Rather than Choosing Start a New Android Project, Open an Existing Project and then
goto file>>new >>new Project
If You create android project by following these steps , You can see every error of you gradle build in
logcat

Execution of spoon task along with running instrumentation test

I have been working on functional testing in Android using Espresso. After adding it successfully I thought of creating reports for the test I added.
For reports I used spoon. Set it up correctly and ran it using the script containing the following command given here
http://square.github.io/spoon/
Query :
But my query was that is there any possibility by which we can run this spoon task run through AndroidStudio menu option that runs functional tests.
Please let me know :
If it is possible at all or not ?
When possible, what to do for the configurations ?
Note : from command line gradle spoon task is working fine and creating reports
Thanks

Robotium (and Robotium Recorder) checking default application and location of test results

I am doing a simple series of tests with Robotium Recorder on Android Studio. I have created my test cases and had a few questions:
One of my tests is to click a URL link and to make sure that the default application dialogue/internet browser is displayed. I don't see an option to do this from the recorder (I wouldn't expect it). I have been looking through the documentation for the solo object and do not see anything that would help me out. There has to be a way to check this.
Once a test is ran from Android Studio, where would the file containing the test results reside?
According to second question: I'm not sure that Robotium already creates any tests reports. You may use for it additional addons like Spoon or Emma.
Read: Creating Test Reports for Android with Spoon and Emma
I know also that Robotium can do a screenshots during the run of tests, but already I don't use this framework so please find on your own how to do it and where screenshots are placec if you feel a bit interesting.
Already, for creating instrumentation tests report I use Gradle. It generates quite good HTML reports. There are at least two ways to make it
in Android Studio, on the left panel, choose Gradle then app, verification, finally connectedAndroidTest
if you're familiar with Unix console go to your project location and just run the command:
./gradlew connectedAndroidTest
NOTE: On the first time it might be needed to run before chmod u+x gradlew, if console would say that you don't have enough permissions to do it.
SUGGESTION: if you make one of your test failed, in generated by Gradle test report you would find a location of HTML generated tests report.
Gradle test report would look like this if all would run successful or this, if at least one would fail.

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

Categories

Resources