title: Kotlin: Unit Test getView method of ArrayAdapter
body: <p>I have the following simple <code>ArrayAdapter</code> that I'd like to run UnitTests on:</p>
  
  <pre><code>class AccountSpinnerAdapter(context: Context, textViewResourceId: Int, private val values: Set&lt;Account&gt;) : ArrayAdapter&lt;Account&gt;(context, textViewResourceId, values.toList()) {
  
      override fun getCount() = values.size
      override fun getItem(position: Int) = values.elementAt(position)
      override fun getItemId(position: Int) = position.toLong()
  
      override fun getView(position: Int, convertView: View?, parent: ViewGroup): View {
          val label = super.getView(position, convertView, parent) as TextView
          label.text = values.elementAt(position).displayName
          return label
      }
  
      override fun getDropDownView(position: Int, convertView: View?, parent: ViewGroup): View {
          val label = super.getDropDownView(position, convertView, parent) as TextView
          label.text = values.elementAt(position).displayName
          return label
      }
  }
  </code></pre>
  
  <p><code>getCount</code>, <code>getItem</code> and <code>getItemId</code> is easily done.</p>
  
  <p>But <strong>how can I test the <code>getView</code> and <code>getDropDownView</code> methods?</strong> Problems that I am facing are:</p>
  
  <ul>
  <li>the 3rd parameter <code>viewGroup</code> can not be <code>null</code>. How to fake/mock this <code>ViewGroup</code>?</li>
  <li>both methods are calling <code>super.xxx</code>. How can I set up a <code>when/then</code> construct to let it return a <code>TextView</code>?</li>
  </ul>