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
Related
I tried putting in the android screenshot testing library written by facebook.
I set up everything as described in the wiki, and then wrote my test, which displayed on the simulator well when i ran it manually. But I want to run it from the command line
So i wrote this line in the command line
./gradlew :instrumentationtestmodule:recordDevDebugAndroidTestScreenshotTest --tests=com.path.to.test.explicit.TestClass --stacktrace
And it started running
connectedAndroidTest
All the possible tests in the other classes
Did not run the record screenshot test.
None of the above is what I wanted to achieve.
How do I record 1 specific test with the android screenshot test?
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.
I am working on a new project for Android. Currently, I am using Android studio as IDE. I need to run Unit test and System (CI) test flows which can be run on both Local machine (JVM) and Emulator/Real Device for instrumentation.
Note that I am running all unit tests via command line.
For get the code coverage of the Emulator/Real Device I am using Jacoco.
and running the following command: gradlew createDebugCoverageReport
However, I can't find any way to run the Local machine unit test with coverage report from command line.
The only way is to run it from the android studio by selecting "Run XXX with Code Coverage":
Can you please advise if it is possible to run local unit test from command line with coverage. And get the report as an html file?
Thanks,
Zachi
If I understood correctly, you are trying to run the tests with coverage ability of the IntelliJ-based Android studio.
It basicly can be done using a Command Line Tool of the IntelliJ.
You can read more about it here, but it generally allows you to accomplish everything that can be done from GUI via the command line:
IntelliJ creating command line tools
For more general info regarding the coverage of the IntelliJ tools you can read here:
IntelliJ Code coverage
Hope it helps, good luck.
At this moment there is no default task to create reporting for Junit (local) tests in the gradle Android tools.
However, it's easy to create those.
Just follow the instructions to integrate the custom jacoco.gradle file here:
https://gist.github.com/mrsasha/384a19f97cdeba5b5c2ea55f930fccd4
You will then have tasks like these: test[Flavor]UnitTestCoverage
So to generate the reports, you just have to:
$ ./gradlew test[Flavor]UnitTestCoverage
The report can be generated using the android studio, after you run the test with coverage the results window appears, click the button bordered with red
Check this image:
By running ./gradlew tasks in the terminal if you are using the gradle wrapper or gradle tasks you will have a list of the available verification tasks (see the screenshot below):
You can refer to this link for more thorough test command lines.
You can use testDebugUnitTest, run it as ./gradlew <your_module_name>:testDebugUnitTest and it will run tests related to this particular module + it will generate an html report under your_module/build/reports/tests/testDebugUnitTest folder, with the coverage.
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/
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