Note that there are some explanatory texts on larger screens.

plurals
  1. POJava generics: How to wrap/extend Android Activity test case?
    primarykey
    data
    text
    <p>I am trying to extend ActivityInstrumentationTestCase2 as follows:</p> <pre><code>public abstract class FooActivityTestCase&lt;T extends Activity&gt; extends ActivityInstrumentationTestCase2&lt;Activity&gt; { public FooActivityTestCase(String pckg, Class&lt;Activity&gt; activityClass) { super(pckg, activityClass); } public void foo(){ ... } } </code></pre> <p>I try to extend <code>FooActivityTestCase</code> like this:</p> <pre><code>public class SpecificFooTestCase extends FooActivityTestCase&lt;MyActivity&gt; { public SpecificFooTestCase() { super("foo.bar", MyActivity.class); // error on this line } } </code></pre> <p>Eclipse gives me the following error in the constructor:</p> <pre><code>The constructor FooActivityTestCase&lt;MyActivity&gt;(String, Class&lt;MyActivity&gt;) is undefined </code></pre> <p>I am pretty sure that the issue is with how I am using generics. When <code>SpecificFooTestCase</code> extends <code>ActivityInstrumentationTestCase2</code> I don't get any errors. Can anybody point out what I am doing wrong?</p> <hr> <p>Kublai Khan's and Michael Myers' suggestions work in conjunction. After I changed <code>FooActivityTestCase</code> to extend <code>ActivityInstrumentationTestCase2&lt;T&gt;</code> and <code>Class&lt;Activity&gt;</code> to <code>Class&lt;T&gt;</code> in the constructor, the classes compile without errors. This is the resulting class (SpecificFooTestCase hasn't changed):</p> <pre><code>public abstract class FooActivityTestCase&lt;T extends Activity&gt; extends ActivityInstrumentationTestCase2&lt;T&gt; { public FooActivityTestCase(String pckg, Class&lt;T&gt; activityClass) { super(pckg, activityClass); } public void foo(){ ... } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload