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

Android, Espresso. How check is soft keyboard is under view?
How to validate whether opened correct activity - Espresso
Espresso Test Failed: Wanted to match 1 intents. Actually matched 0 intents
How test onData() column value is not null?
Android, Espresso: Is one view is under another view?
Espresso: How fast show new activity?
Android, Espresso: Show/Hide view depends of item content
Android. Unit test. Check is text is show in correct language
Cucumber Espresso and Android : How to use view matchers to find the particular view using resource id?
how to re-run failed tests using AndroidJunit4?
Espresso: typeText - not work in cyrilic
Espresso test - not recognize ad
Espresso: How do i assert if a particular activity is launched when i click on a item using espresso
Android, Espresso: How check if tag value contains some string?
I want to scroll on recycler view till the element appears on screen, it may make network calls after each 10 elements.
Mock server requests Android Espresso UI Testing

Categories

HOME
user-interface
tomcat
opencv-python
writefile
enums
hid
informatica
turbojpeg
drag-and-drop
scheduler
responsive-design
cocotb
fireloop
watch-os-3
buffer
responsivevoice
xbap
ex
global-variables
google-cloud-logging
pinterest
vertica
mixpanel
error-logging
conda
ava
firemonkey-style
list-comprehension
bobo-browse.net
fatfs
intune
dotcms
code-rally
hidden-markov-models
classnotfoundexception
optionaldataexception
git-tfs
docker-ucp
liteide
adblock
nothing
watir-webdriver
ptvs
connect-direct
wikimapia
dtd
pecl
word-2016
degrees
ltrace
rustdoc
openerp-6
oracle-fusion-apps
gapi
decoder
dmarc
always-on-top
seccomp
between
nsdata
wicked-pdf
jsr363
univocity
decidable
self
apache-commons-digester
extend
wlanapi
supersocket.net
bootstrap-wysiwyg
relational-model
kefir.js
innerhtml
python-c-extension
subview
phonegap-facebook-plugin
dnsjava
cout
coding-efficiency
rpg
windows-messages
forio-contour
sql-function
strcmp
mute
ax
insertion
oembed
ntlmv2
gprof
jquery-dialog
daap
viewpagerindicator
taskkill
play2-mini
uipasteboard
channelfactory
j2mepolish
iphone-sdk-3.1.3
stretchblt
remote-working
rendering-engine
error-detection

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