android - Get activity `ViewDataBinding` field inside `Robolectric` unit test after being assigned -


i writing robolectric unit test requires me make use of activity under test view data binding class(viewdatabinding), unfortunately no luck stuck being null inside of unit test

inside of mainactiviy class:

... activitymainbinding binding; // <-- field returns null inside unit test ... @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     binding = databindingutil.setcontentview(this, r.layout.activity_main); } ... 

if has written test similar requirement please demonstrate example of how got viewdatabinding classed assigned before test completed. thanks!

note: using android studio 2.2

i found out testing robolectric version 3.1 issue , after upgrading using robolectric version 3.1.4 activities viewdatabinding field no longer returning null

see pr: https://github.com/emartynov/android-architecture/pull/1

thanks @eugenmartynov contribution towards issue.

note: used gradle version 3.1 building project, if decide use gradle version 3.1 , experience other issues after upgrading.kindly @ gradles change logs update gradle build scripts(build.gradle) accordingly, before commenting other unrelated issues.


Comments

Popular posts from this blog

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - SSE Emitter : Manage timeouts and complete() -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -