Comments (8)
Lets find it out who needs work ...
Get you coverage report when you run connectedCheck (espresso tests)? When yes then dagger + jacoco works together and it should be possible with robolectric.
Create a sample project setup with dagger to show us your error, then we can try out. Class not found mean most times it is missing in the classpath. Try out to play with this line classDirectories = fileTree(dir: '../AndroidSample/build/classes/debug', exclude: 'com/example/R*.class')
What is your intention to use dagger? Maybe it would be enough to use AndroidAnnotions as your dependency injection framework.
from android-gradle-template.
I'm planning to create a few sample applications in the upcoming week. I'll keep you informed.
from android-gradle-template.
It's about injection which is not compatible with jacoco I guess, both Butterknife as Dagger are not compatible after testing some things.
from android-gradle-template.
As it's not mentioned here, at least those projects can have coverage with excluding the generated classes: exclude: '/$.class'
from android-gradle-template.
have you tried it or maybe @josomers could you try it please?
current i don't plan to include dagger or butterknife until someone has a good reason for me. But I would be glad if someone found a way to get it work and share it with me. Then i will mention it in the wiki how to include dagger or butterknife and get this code under test.
from android-gradle-template.
Very nice suggestion by @dpreussler! I tried and modified it a little, but this is my working solution: https://gist.github.com/josomers/9f90b017e321c54bb918
Make sure to replace 'my-project' with the name of your project.
from android-gradle-template.
here is a solution without excluding the generated files http://chrisjenx.com/gradle-robolectric-jacoco-dagger/
the main part is to add following part inside jacocoTestReport { }
doFirst {
new File('myapp/build/intermediates/classes/').eachFileRecurse { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
from android-gradle-template.
i use the solution with my project , task skipped.
my build.gralde
apply plugin: 'jacoco'
android {
buildTypes {
debug {
testCoverageEnabled true
}
}
jacoco {
version "0.7.1.201405082137"
}
def coverageSourceDirs = [
'src/main/java',
]
task jacocoTestReport(type: JacocoReport) {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
reports {
xml.enabled = true
html.enabled = true
}
classDirectories = fileTree(
dir: './build/intermediates/classes/debug',
excludes: ['**/R*.class',
'**/*$InjectAdapter.class',
'**/*$ModuleAdapter.class',
'**/*$ViewInjector*.class'
])
sourceDirectories = files(coverageSourceDirs)
executionData = files("$buildDir/jacoco/testDebug.exec")
doFirst {
new File("$buildDir/intermediates/classes/").eachFileRecurse { file ->
if (file.name.contains('$$')) {
file.renameTo(file.path.replace('$$', '$'))
}
}
}
}
result:
./gradlew jacocoTestReport --stacktrace
setup
create beta
cleanPublish:/home/sunhao/Project/android/build/apks
:app:jacocoTestReport SKIPPED
BUILD SUCCESSFUL
Total time: 21.856 secs
from android-gradle-template.
Related Issues (20)
- Project Structure Question HOT 1
- A problem occurred evaluating project ':ComponentTestsRobolectric' HOT 6
- When using this template, I've faced some problems HOT 3
- jacoco with espresso, task jacocoTestReport skipped HOT 6
- Error Illegal use of non virtual function call HOT 4
- Maybe switch to JCAndKSolutions/android-unit-test
- 'android' or 'android-library' plugin is required HOT 8
- Illegal use of nonvirtual function call HOT 2
- Collect code coverage during manual testing? HOT 2
- Update to latest version of Espresso and Mockito? HOT 3
- Voting: Which is your favourite way to support robolectric? HOT 5
- Can not compile success in the environment Android Studio1.0+ gradle2.2.1+build gradle1.0 HOT 3
- Unexpected top-level exception when running app HOT 2
- Could not find com.novoda:gradle-android-test-plugin:0.10.3. HOT 3
- run-tests.sh needs a simple fix HOT 1
- Android Studio 1.4 Java modules cannot depend on Android modules HOT 2
- Running / debugging Unit or Component tests in Android Studio HOT 3
- Unable to import project HOT 5
- oops
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android-gradle-template.