android-espresso


Android Instrumentation pull test results/files from device


During my attempt of porting a BDD library to Android JUnit runner I came to a deadlock how to properly pull the data back from the test run.
I presume I have 2 options:
Save the "BDD model results" on the device and pull them after the test run finishes
//reportFile==/data/data/com.packagename.app/cache/jgiven
new ScenarioJsonWriter( model ).write( reportFile );
Send the data back to instrumentation caller back during test runs so he saves it in some results output dir
Questions:
How to do 1. in a stable and proper way without changing app permissions to write to external storage, or adb vodoo (root, run-as etc)
Or how to do 2. properly which I would preffer, I can create a RunListener that would log these infos to am raw, or logcat, but still this does not feel right, how to write a gradle plugin that would hook up to these am raw results and save them to some file during test execution
public class JGivenTestRunListener extends InstrumentationResultPrinter {
private static final String LOG_TAG = "JGivenTestRunListener";
/**
* This value, if stored with key {#link android.app.Instrumentation#REPORT_KEY_IDENTIFIER},
* identifies AndroidJUnitRunner as the source of the report. This is sent with all
* status messages.
*/
public static final String REPORT_VALUE_ID = "AndroidJUnitRunner";
/**
* Used for sending scenario model json to the instrumentation for further processing
*/
public static final String REPORT_KEY_JGIVEN_SCENARIO_MODEL = "scenariomodel";
Bundle jgivenTestResult;
private final Bundle mJgivenResultTemplate;
public JGivenTestRunListener() {
mJgivenResultTemplate=new Bundle();
}
#Override
public void testRunStarted(Description description) throws Exception {
mJgivenResultTemplate.putString(Instrumentation.REPORT_KEY_IDENTIFIER, REPORT_VALUE_ID);
jgivenTestResult=new Bundle(mJgivenResultTemplate);
super.testRunStarted(description);
}
#Override
public void testFinished(Description description) throws Exception {
ReportModel reportModel = ScenarioModelHolder.getInstance().getAndRemoveReportModel(description.getTestClass());
String reportJson = new ScenarioJsonWriter(reportModel).toString();
Log.e("REPORT",reportJson);
jgivenTestResult.putString(REPORT_KEY_JGIVEN_SCENARIO_MODEL, reportJson);
jgivenTestResult.putString(Instrumentation.REPORT_KEY_STREAMRESULT, "");
sendStatus(0,jgivenTestResult );
super.testFinished(description);
}
}
Any suggestion how to solve this issue?

Related Links

Espresso mockWebServer response does not intercept http calls
Android Instrumentation pull test results/files from device
Espresso hangs the UI and the System kills the application
Espresso test with phone asleep
Unable to run espresso test
How to force Espresso wait for Eventbus posts?
Espresso Web + Chrome cust tab
Espresso 2 - How to Test Multiple Activities?
Android Espresso test to check syncness between ViewPager's fragments and TabViews
Is there a way to automate API calls using Espresso?
Android Espresso - Single list with same items (AmbiguousViewMatcherException)
Do Matchers extending hamcrest.BaseMatcher have to be consistent
testing http connection on google cloud test lab devices
Espresso Test Recorder has detached from the device VM
Espresso - Using google espresso how to send email from Gmail app
Unable to perform PressBack in Espresso Test

Categories

HOME
jboss
openshift
extjs
matrix
nsis
liferay-7
dependencies
qooxdoo
navigation
supercollider
migrate
vimeo
amazon-elb
global-variables
supervisord
android-5.1.1-lollipop
uima
home
error-logging
activeadmin
react-dnd
background-color
points
basex
progid
series
shapeless
quickcheck
nsuserdefaults
eclipse-gmf
iscroll
system-on-chip
fiware-wirecloud
vungle-ads
elasticsearch-aggregation
spooler
qvtkwidget
section508
lightning-workbench
spring.net
exc-bad-access
android-mediarecorder
google-shopping-api
nrf51
bpms
yargs
haraka
scheduledexecutorservice
nvda
callouts
jenkins-workflow
deferred-rendering
adp
vaadin4spring
swiffy
google-gdk
cache-manifest
unidata
scala-swing
nssortdescriptor
subview
rebar
libgcc
roxy-fileman
acitree
form-for
pacman
background-thread
android-authenticator
django-filebrowser
ckeditor.net
idispatch
getproperty
chronometer
border-box
jdom
firebird1.5
microblogging
database-deadlocks
qcar-sdk
regression-testing
principles
source-code-protection
eai
server-load
chronic

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App