Android Gradle two instrumentation test suites - android

I am trying to set up a second instrumentation test suite for an android project. The project builds under Gradle and the ADT plugin.
I have instrumentationTestSuiteA and instrumentationTestSuiteBand buildTypeAand buildTypeB.
I would like instrumentationTestSuiteA to run on buildTypeA, and instrumentationTestSuiteB on buildTypeB.
How could I accomplish this?

Related

Gradle with Mockito and MockMaker plugin

Trying to handle a problem with mocking Kotlin final classes. I used org.mockito:mockito-inline libs that uses org.mockito.plugins.MockMaker.
All works fine when start tests from Android Studio, but when I use "gradlew test" command I get error
"java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker" the reason
Can anyone suggest hot to run test via gradle just like if the test is run from Android Studio?

Generating Code Coverage Report with Android Studio 1.0

I'm trying to generate a Code Coverage report using Android Studio and the gradle plugin.
I've done alot of research and seem to have found that using the jacoco plugin is the way to do it. I currently only have instrumentation and junit tests which I run with the gradle wrapper using gradle 1.13 that I execute with ./gradlew connectedCheck.
The appropriate part of my gradle file looks like this:
mock.initWith(debug)
mock {
testCoverageEnabled true
}
Upon doing so it generates a coverage.ec file that I have no idea what to do with. Apparently you need a coverage.em file for emma to compile it but I'm not sure where to generate that.
I've also tried this without a gradle wrapper using gradle 2.2.1
According to http://gradle.org/docs/current/userguide/jacoco_plugin.html#jacoco-application-output it should be generating an html file with the coverage report in it but I am unable to do so. Does anyone have any great tutorials or a way to use the coverage.ec file?

Android: project set up for unit and functional tests

I'm trying to incorporate more unit tests, specifically Robolectric test into my project. Right now I already have some functional test that are in my androidTest package. The problem is that if I add a Robolectric Test Class to that package then when I execute ./gradlew test all the functional test are ran along with the Robolectric/Unit Tests.
Is best practice to be using a different test package for my unit tests? And if that's the case then will I have to configure the Gradle test task to look at only the unit test package?
I should mention that I'm on Android Studio 1.0, Gradle 1.0, and Robolectric 2.4.
./gradle test runs all the test in your project. You will likely have (at least) two modules in your project, lets call them app and robolectric-tests.
You can tell Gradle to run a task on a specific module by using ./gradlew :module:task. So in your case, you could run ./gradlew :robolectric-tests:test to run only your Robolectric tests.

Android gradle build that code coverage for robolectric tests

Is there a way to to have a gradle build that will generate code coverage from robolectric test that can be sent to sonar?
As far as I can tell: At this time, No.
In order to have code coverage you need Emma support and that's not yet fixed in the android gradle build plugin. It's supposed to come in version 0.8.+ but it was also "supposed" to come in version 0.6+ so don't hold your breath.
Roadmap: http://tools.android.com/tech-docs/new-build-system/roadmap
Related Emma Issue: https://code.google.com/p/android/issues/detail?id=60964

Generate code coverage reports for Android Maven Library Project

I have a Android Library project and an Android Test project.
The test project has Android dependency and junit dependency.
The modules are:
MyProject
MySample
MyProjectTest
MySample uses MyProject as a library and gives an apk as output.
MyProjectTest has MySample as dependency and it has the test cases.
The unit test cannot run on jvm. That is why MySample project is used which generates an apk and the unit tests can run on the emulator. They run as instrumented tests as they need an emulator to execute.
There are lots of documentation available for an ant build but very few for maven android project.
I have configured emma for code coverage, but the coverage files are not generated.
My poms follow this link.https://code.google.com/p/maven-android-plugin/wiki/EmmaMaven with the following modification.
The tested.project.dir is set to MySample
/data/data/(package of MySample)/files/coverage.ec in property pullSource
I get the error: "Cannot pull coverage.ec from device as it doesnt exist."
Please help. Any pointer to the same is much appreciated.
Also I am open to any coverage tools. My only constraint is I need to test Maven Android Library Project.
I tried with cobertura too but still couldnt generate any coverage reports.

Categories

Resources