Comments (22)
Do you need to ask more question regarding this issue ? Please help me solving this it would be great if any help comes..
from newspaper.
Since all the duplicate files have the path app/build/test-results/
, it seems there were 2 or more jobs that persisted to app/build/test-results/
and later it tried to attach them and raised the error.
So,
- Is the
config.yml
shown here complete? - Can you check earlier jobs to see which jobs persisted to
c442a392-036b-43f5-a326-102af4f553b1
andd2540856-c8b8-45a7-8403-b57d0be7e982
? You can checkSpin up environment
sub-task in CircleCI, and look for something likeCIRCLE_WORKFLOW_JOB_ID=c442a392-036b-43f5-a326-102af4f553b1
to check the workspace ID.
from newspaper.
Thanks for your reply means alot.
- yes the config.yml is complete/
- yes both these jobs(build_debug and test_unit ) persist app/build/test-results/ this is same from your reference.
Pardon me if i am wrong actually I am new into this.. - Also one more doubt sometimes my test cases run perfectly on firebase sometimes they get stuck are these test cases flaky or it happens with me only :/
from newspaper.
The line ./gradlew lint test
in job build_debug
caused the problem. build_debug
is intented to assemble the binaries for use in later stage (without any test result files), and test_unit
will generate test results under test-results
path. So the generated files from these 2 jobs are mutually exclusive. But if you execute lint test
in build_debug
, it will generates the same unit test result files as in test_unit
.
You may consider any of these suggestions (but not all):
- Persist the generated files in
build_debug
to somewhere else - Do not perform any test in
build_debug
- Move any test to
test_unit
(or to a new job)
Hope it helps.
from newspaper.
If you got stuck in an instrumented test, quite often it was caused by some animation or any moving screen elements. Espresso waits for all animations to complete and execute your test only when it detects the main thread is idle.
You can troubleshoot the tests by examining the recorded video in Firebase to see what happened when the test failed.
from newspaper.
Okay Thanks a lot i will try the 2nd solution and hope it works .
from newspaper.
Also after analyzing the videos I have realized that its the problem of animation as using Thread.sleep() with small amt. of time causes the problem.
from newspaper.
The solution works like a charm,But what are the steps to generate the code coverage report the report has been generated in the instrumented test case by the name of coverage.ec but where to view the code coverage does this below mentioned commented code code has any use ?
# - run: name: Upload coverage report to Codacy command: ./gradlew -PciBuild=true uploadCoverageToCodacy - run: name: Upload coverage report to CodeCov command: bash <(curl -s https://codecov.io/bash)
Thanks for the solution and thanks in advance..
from newspaper.
To generate a combined coverage report for unit tests and instrumented tests, you need to tell JaCoCo where the generated coverage binary files are in your build.gradle
. See below for reference:
https://github.com/ayltai/Newspaper/blob/develop/mobile/build.gradle#L313
The JaCoCo XML report is specified here: https://github.com/ayltai/Newspaper/blob/develop/mobile/build.gradle#L333
The HTML one should be in somewhere inside the build directories, but I forgot where.
Also, check this article for a detailed explanation:
https://medium.com/@rafael_toledo/setting-up-an-unified-coverage-report-in-android-with-jacoco-robolectric-and-espresso-ffe239aaf3fa
from newspaper.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
This above is the coverage report from jacoco which means my coverage report is not generated
jacoco {
toolVersion '0.7.4.201502262128'
}
task jacocoTestReport(type: JacocoReport) {
sourceDirectories = files()
classDirectories = files()
executionData = fileTree(
dir : "$buildDir",
include : [ 'outputs/code-coverage/connected/*coverage.ec' ]
)
reports {
xml.enabled true
html.destination file("${buildDir}/jacocoHtml")
csv.enabled false
}
onlyIf = {
true
}
}
This is my jacocoTestReport task please help ..?
from newspaper.
You are specifically telling JaCoCo to include instrumented test report only by having this line:
include : [ 'outputs/code-coverage/connected/*coverage.ec' ]
.
You can try:
- Enable HTML report (refer to https://github.com/ayltai/Newspaper/blob/develop/mobile/build.gradle#L286).
- Clean the project.
- Run unit tests (
testDebugUnitTest
). - Check where your unit test binary report is generated (e.g.
build/jacoco/testDebugUnitTest.exec
). - Change the line to:
include : [
jacoco/testDebugUnitTest.exec, 'outputs/code-coverage/connected/*coverage.ec' ]
. You may need to edit the paths according to the actual paths in your project (refer to https://github.com/ayltai/Newspaper/blob/develop/mobile/build.gradle#L313).
from newspaper.
how can we check where the file coverage.exec has been generated its not visible in the circleci artificats
https://circleci.com/bb/stratbeans/app_lms_android/685
from newspaper.
You can run tests on your local machine, e.g. run the command ./gradlew testDebugUnitTest
on your PC or Mac. The result will be the same.
from newspaper.
yes the file is getting generated but can you help while converting this exec file into .html jacoco report the report comes out to be empty
https://710-332c79fd-fcb5-43d4-9f19-4cdc2087010e-bb.circle-artifacts.com/0/reports/jacoco/jacocoTestReport/html/index.html
Please refer to this link
from newspaper.
I have one doubt maybe it sounds silly
To generate code coverage why cant we run emulator in circleci and run the command ./gradlew createDebugCoverageReport instead of jacoco as in my case jacoco is not doing anything
Please help me in generating code coverage using jacoco this is my gradle :-
jacoco {
toolVersion '0.7.4.201502262128'
}
def coverageSourceDirs = [
'src/main/java'
]
task jacocoTestReport(type: JacocoReport) {
// def debugTree = fileTree(dir: app/buid/intermediates/classes/debug, excludes: fileFilter)
// def mainSrc = app/src/main/java
classDirectories = fileTree(
dir: 'build/intermediates/classes/debug',
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)
sourceDirectories = files(coverageSourceDirs)
// classDirectories = files(coverageSourceDirs)
executionData = fileTree(
dir : "$buildDir",
include : [ 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec' ]
)
reports {
xml.enabled false
html.enabled = true
csv.enabled false
}
onlyIf = {
true
}
}
And the config.yml is attached above also both the files .exec and .ec have been generated still no code covearge can be seen using jacoco pls help it is only showing this blank html page
https://710-332c79fd-fcb5-43d4-9f19-4cdc2087010e-bb.circle-artifacts.com/0/reports/jacoco/jacocoTestReport/html/index.html
from newspaper.
Did you turn on test coverage report in build.gradle
? Something like this:
buildTypes {
debug {
testCoverageEnabled true
}
}
You should really try to run Gradle commands to generate JaCoCo reports locally first, not on CIrcleCI, to see if everything runs fine and you can get your report locally.
Btw, I don't have access to your CicleCI project so I can't open your link.
from newspaper.
The report is coming fine locally but not on circleci jacocoreport task has been attached.
jacoco {
toolVersion '0.7.4.201502262128'
}
def coverageSourceDirs = [
'src/main/java'
]
task jacocoTestReport(type: JacocoReport) {
// def debugTree = fileTree(dir: app/buid/intermediates/classes/debug, excludes: fileFilter)
// def mainSrc = app/src/main/java
classDirectories = fileTree(
dir: 'build/intermediates/classes/debug',
excludes: ['**/R.class',
'**/R$*.class',
'**/*$ViewInjector*.*',
'**/BuildConfig.*',
'**/Manifest*.*']
)
sourceDirectories = files(coverageSourceDirs)
// classDirectories = files(coverageSourceDirs)
executionData = fileTree(
dir : "$buildDir",
include : [ 'jacoco/testDebugUnitTest.exec', 'outputs/code-coverage/connected/*coverage.ec' ]
)
reports {
xml.enabled false
html.enabled = true
csv.enabled false
}
onlyIf = {
true
}
}
Please tell me if i am doing anything wrong
from newspaper.
and in case of build debug
buildTypes {
debug {
testCoverageEnabled true
}
testcoverage is enabled
from newspaper.
ok if you got the report locally, make sure you are copying the files from the correct artifact paths in CircleCI.
Did you update your config.yml
since you mentioned that you will remove tests from build_debug
job? Please show the updated one here.
from newspaper.
# Reference : https://github.com/ayltai/Newspaper/blob/master/.circleci/config.yml
version: 2
references:
cache_key: &cache_key
key: cache-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
restore_cache: &restore_cache
restore_cache:
<<: *cache_key
save_cache: &save_cache
save_cache:
<<: *cache_key
paths:
- ~/.gradle
- ~/.m2
workspace: &workspace
~/workspace
attach_debug_workspace: &attach_debug_workspace
attach_workspace:
at: *workspace
attach_release_workspace: &attach_release_workspace
attach_workspace:
at: *workspace
persist_debug_workspace: &persist_debug_workspace
persist_to_workspace:
root: *workspace
paths:
- app/build/outputs/androidTest-results
- app/build/outputs/apk
- app/build/outputs/code-coverage
- app/build/test-results
persist_release_workspace: &persist_release_workspace
persist_to_workspace:
root: *workspace
paths:
- app/build
attach_firebase_workspace: &attach_firebase_workspace
attach_workspace:
at: *workspace
persist_firebase_workspace: &persist_firebase_workspace
persist_to_workspace:
root: *workspace
paths:
- firebase
## Docker image configurations
android_config: &android_config
working_directory: *workspace
docker:
- image: circleci/android:api-27-alpha
environment:
TERM: dumb
_JAVA_OPTIONS: "-Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m"'
gcloud_config: &gcloud_config
working_directory: *workspace
docker:
- image: google/cloud-sdk:latest
environment:
TERM: dumb
export_android_key: &export_android_key
run:
name: Export Android key store environment variable
command: echo 'export ANDROID_KEY_STORE="$ANDROID_KEY_STORE"' >> $BASH_ENV
decode_android_key: &decode_android_key
run:
name: Decode Android key store
command: echo $ANDROID_KEY_STORE | base64 -di > key-store.jks
export_gservices_key: &export_gservices_key
run:
name: Export Google Services key environment variable
command: echo 'export GOOGLE_SERVICES_KEY="$GOOGLE_SERVICES_KEY"' >> $BASH_ENV
decode_gservices_key: &decode_gservices_key
run:
name: Decode Google Services key
command: echo $GOOGLE_SERVICES_KEY | base64 -di > app/google-services.json
export_gcloud_key: &export_gcloud_key
run:
name: Export Google Cloud Service key environment variable
command: echo 'export GCLOUD_SERVICE_KEY="$GCLOUD_SERVICE_KEY"' >> $BASH_ENV
decode_gcloud_key: &decode_gcloud_key
run:
name: Decode Google Cloud credentials
command: echo $GCLOUD_SERVICE_KEY | base64 -di > client_secrets.json
export_fabric_key: &export_fabric_key
run:
name: Export Fabric key
command: echo 'export FABRIC_KEY="$FABRIC_KEY"' >> $BASH_ENV
decode_fabric_key: &decode_fabric_key
run:
name: Decode Fabric key
command: echo $FABRIC_KEY | base64 -di > app/fabric.properties
jobs:
build_debug:
<<: *android_config
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- store_artifacts:
path: app/build/reports
destination: reports
- run:
name: Gradle build (debug)
command: ./gradlew -PciBuild=true :app:assembleDebug :app:assembleAndroidTest
- *persist_debug_workspace
- store_artifacts:
path: app/build/outputs/apk/
destination: /apk/
build_release:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- run:
name: Gradle build (release)
command: ./gradlew -PciBuild=true :app:assembleRelease
- *persist_release_workspace
- store_artifacts:
path: app/build/outputs/apk/
destination: /apk/
- store_artifacts:
path: app/build/outputs/mapping/
destination: /mapping/
test_unit:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- run:
name: Run unit tests
command: ./gradlew -PciBuild=true :app:testDebugUnitTest
- run:
name: Run Tests
command: ./gradlew lint test
- *persist_debug_workspace
- store_artifacts:
path: app/build/reports/
destination: /reports/
- store_test_results:
path: app/build/test-results/
destination: /test-results/
test_instrumented:
<<: *gcloud_config
steps:
- *attach_debug_workspace
- *export_gcloud_key
- *decode_gcloud_key
- run:
name: Set Google Cloud target project
command: gcloud config set project mobius-enterprise-e6854
- run:
name: Authenticate with Google Cloud
command: gcloud auth activate-service-account firebase-adminsdk-vflyj@mobius-enterprise-e6854.iam.gserviceaccount.com --key-file client_secrets.json
- run:
name: Run instrumented test on Firebase Test Lab
command: echo y | apt-get install ant && ant -version clean emma debug install test && gcloud firebase test android run --type instrumentation --app app/build/outputs/apk/debug/app-debug.apk --test app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk --device model=Nexus5X,version=26,locale=en_US,orientation=portrait --environment-variables EMMA_INSTRUMENT=true,coverage=true,coverageFile=/sdcard/coverage.ec --directories-to-pull=/sdcard --timeout 20m
no_output_timeout: 1200
- run:
name: Create directory to store test results
command: mkdir firebase
- run:
name: Download instrumented test results from Firebase Test Lab
command: gsutil -m cp -r -U "`gsutil ls gs://test-lab-ubqdpqunat3jx-k45t9wpaarc4a | tail -1`*" /root/workspace/firebase/
- *persist_firebase_workspace
- store_artifacts:
path: firebase/
destination: /firebase/
report_coverage:
<<: *android_config
steps:
- checkout
- *restore_cache
- run:
name: Download dependencies
command: ./gradlew androidDependencies
- *attach_debug_workspace
- *attach_firebase_workspace
- run:
name: Move Firebase coverage report
command: mkdir -p app/build/outputs/code-coverage/connected && cp firebase/Nexus5X-26-en_US-portrait/artifacts/coverage.ec app/build/outputs/code-coverage/connected/coverage.ec
- run:
name: Generate JaCoCo report
command: ./gradlew -PciBuild=true :app:jacocoTestReport --stacktrace
store_artifacts:
path: app/build/reports/
destination: /reports/
workflows:
version: 2
workflow:
jobs:
- build_debug
- build_release
- test_unit
- test_instrumented:
requires:
- build_debug
- report_coverage:
requires:
- test_unit
- test_instrumented
#- deploy:
# filters:
# branches:
# only:
# - master
#requires:
# - build_release
#- test_unit
#- test_instrumented
from newspaper.
I notice that you run both gradlew testDebugUnitTest
and gradlew test
in build_debug
job. Why doing both? gradlew test
includes testing your debug build and release build. Did it pass for the release build? Can you run gradlew test
locally without errors? If it encounters any error, it aborts the test step and there will be no report generated.
from newspaper.
thanks for your help pls close the issue i am able to generate unified coverage report now !
Thanks a lot +1
from newspaper.
Related Issues (20)
- io.reactivex.c.f: java.net.SocketTimeoutException: connect timed out HOT 1
- io.reactivex.c.d: Connection reset
- io.reactivex.c.f: java.lang.RuntimeException: java.lang.NoSuchMethodException: init [interface org.simpleframework.xml.a.ag, interface org.simpleframework.xml.f, class org.simpleframework.xml.d.i] HOT 1
- io.reactivex.c.f: java.net.SocketException: Software caused connection abort HOT 1
- io.reactivex.c.f: java.lang.RuntimeException: org.simpleframework.xml.core.PersistenceException: Constructor not matched for class com.github.ayltai.newspaper.f.a HOT 1
- io.reactivex.c.d: Illegal Argument: Provided schema version 1 is less than last set version 17. HOT 1
- java.lang.RuntimeException: Canvas: trying to use a recycled bitmap android.graphics.Bitmap@4bac6930
- java.lang.NullPointerException: Attempt to invoke virtual method void com.github.ayltai.newspaper.speech.SimpleTextToSpeech.shutdown() on a null object reference HOT 1
- Remove extra HTML formatting
- io.reactivex.exceptions.OnErrorNotImplementedException: Jetty ALPN/NPN has not been properly configured. HOT 1
- io.reactivex.exceptions.OnErrorNotImplementedException: Null accessToken HOT 1
- io.reactivex.exceptions.OnErrorNotImplementedException: HTTP 400 HOT 1
- Acceptance tests (Cucumber) HOT 1
- Housekeeping
- Integrate Litho HOT 1
- Broken coverage data file HOT 1
- Generating code coverage in Firebase test lab
- Cannot Lanucnh Emulator HOT 3
- Question on code coverage HOT 1
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 newspaper.