Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code coverage for monkeyrunner using JaCoCo #17

Open
jeffcomlin opened this issue Oct 21, 2013 · 1 comment
Open

Code coverage for monkeyrunner using JaCoCo #17

jeffcomlin opened this issue Oct 21, 2013 · 1 comment

Comments

@jeffcomlin
Copy link

I tried updating the profile for monkeyrunner as below. But the app crashes when the test runs and this happens only on instrumented build.

I am looking for some insight on this.

Thanks,
Jeff

Error:

W/dalvikvm( 6413): VFY: invoke type does not match method type of Lcom/abc/xyz/model/Article;._getPartsMap

Useful link:

https://groups.google.com/forum/#!topic/android-platform/KUwF6KJDb70

Useful comment from the link:

I figured it out!

Turns out that the methods which were not getting executed from the
constructor were private and final. However, the byte-compiler of
Rhino was emitting invoke-virtuals in the constructor for those
methods. dx faithfully converted them and retained their invoke-
virtual character. I changed them to invooke-direct with the effect
that the compilation now works! Thanks for all your help!

My experiment:

Changed _getPartsMap from private to public.
It stopped complaining about _getPartsMap and complained about the next. I change the next method to public and it went on to the once after that.

I don't think making these methods public is a solution, but I am hoping it might have some clues.

Rest of the error message: (Below is the error message I see after Dalvikvm error, mentioned above)

E/AndroidRuntime(14361): FATAL EXCEPTION: main
E/AndroidRuntime(14361): java.lang.RuntimeException: Unable to create application <app_package>.MainApplication: java.lang.IllegalStateException: Could not construct instance of helper class class <app_package>.persistence.ApplicationOpenHelper
...
...
Caused by: java.lang.IllegalArgumentException: Unknown class specified for dataClass: <app_package>.model.Article

pom.xml:

${jacoco-plugin.version} is set to 0.6.4-SNAPSHOT

<profile>
    <id>monkeyrunner</id>
    <dependencies>
        <dependency>
            <groupId>org.jacoco</groupId>
            <artifactId>org.jacoco.agent</artifactId>
            <version>${jacoco-plugin.version}</version>
            <classifier>runtime</classifier>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-plugin.version}</version>
                <executions>
                    <execution>
                        <id>instrument-classes</id>
                        <goals>
                            <goal>instrument</goal>
                        </goals>
                        <configuration>
                            <excludes>
                                <exclude>*test*</exclude>
                                <exclude>*/test/*</exclude>
                            </excludes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>restore-instrumented-classes</id>
                        <phase>package</phase>
                        <goals>
                            <goal>restore-instrumented-classes</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.jayway.maven.plugins.android.generation2</groupId>
                <artifactId>android-maven-plugin</artifactId>
                <configuration>
                    <monkeyrunner>
                        <skip>false</skip>
                        <injectDeviceSerialNumberIntoScript>true</injectDeviceSerialNumberIntoScript>
                        <createReport>true</createReport>
                        <programs>
                            <program>
                                <filename>src/test/monkeyrunner/testFile.py</filename>
                            </program>
                            <!-- Monkey Tests go here <program> <filename>src/test/monkeyrunner/example-test.py</filename> 
                                </program> <program> <filename>src/test/monkeyrunner/example-test2.py</filename> 
                                </program> -->
                        </programs>
                    </monkeyrunner>
                </configuration>
                <executions>
                    <execution>
                        <id>install-app</id>
                        <phase>install</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>run-monkey-runner</id>
                        <phase>install</phase>
                        <goals>
                            <goal>monkeyrunner</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</profile>
@jeffcomlin
Copy link
Author

@stephanenicolas Could you please take a peek at this? If you can share some suggestions or pointers, I will definitely look into this further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant