Android Unittesting with Databinding
<p>I'm now working on a very good project, where we introduced Android databinding. Everything works fine in the code, binding perfectly, but when it comes to unit testing I'm not able to test my code. 
I'm struggling to MOCK the databinding...</p>

<p>When adding this line to <strong>setUp()</strong> method:</p>

<blockquote>
  <p>PowerMockito.when(DataBindingUtil.class, "inflate", inflater,anyInt(),any(ViewGroup.class),anyBoolean()).thenReturn(viewDataBinding.getRoot());</p>
</blockquote>

<p>I'll have the following error message:</p>

<blockquote>
  <p>...thenReturn() may be missing.</p>
</blockquote>

<p>As you can see, I have thenReturn at the end, but Mockito doesn't see it.</p>

<p>I tried to move the code into a concrete test method:</p>

<pre><code>  @Test
public void createViewHolder() {
  .... CODE....
 when(DataBindingUtil.inflate(inflater,anyInt(),any(ViewGroup.class),anyBoolean())).thenReturn(viewDataBinding);
... CODE ...}
</code></pre>

<p>In this case I'll have the following message:</p>

<blockquote>
  <p>org.mockito.exceptions.misusing.WrongTypeOfReturnValue: 
  ViewDataBinding$$EnhancerByMockitoWithCGLIB$$f5f40ad1 cannot be returned by inflate()
  inflate() should return View</p>
</blockquote>

<p>I don't understand, why I getting this message, since DataBindingUtil.inflate is returning a ViewDataBinding in the code, where it's works perfectly. 
Have any of you ever tried to mock and unit test data binding on Android?</p>