Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Setup for non-maven

Received: by 10.58.151.78 with SMTP id uo14mr12786956veb.17.1351630502579;
        Tue, 30 Oct 2012 13:55:02 -0700 (PDT)
X-BeenThere: robolectric@googlegroups.com
Received: by 10.52.26.41 with SMTP id i9ls446938vdg.2.gmail; Tue, 30 Oct 2012
 13:55:02 -0700 (PDT)
Received: by 10.52.76.36 with SMTP id h4mr5582357vdw.17.1351630502072;
        Tue, 30 Oct 2012 13:55:02 -0700 (PDT)
Date: Tue, 30 Oct 2012 13:55:01 -0700 (PDT)
From: Thomas H <thomas.heilbron...@googlemail.com>
To: robolectric@googlegroups.com
Message-Id: <34ff30ee-e9b3-4d6e-8a0f-241486d8cb6b@googlegroups.com>
In-Reply-To: <CAGwyn-Pf1RcjdfN8WUmZys488zmjjDYkHZFOTcB47dX_oBdf6w@mail.gmail.com>
References: <44edcaf5-748d-4f6a-a480-4a53e4f96f16@googlegroups.com>
 <e9b27290-71fd-42d2-ac37-0b0654ca6733@googlegroups.com> <3d482a5b-ff76-4ce7-9e33-7ecba2a1cdad@googlegroups.com>
 <e5a4ced3-23b3-49fe-990f-94a94a620355@googlegroups.com> <e94e0bfa-cc31-4e7a-8441-cec7d4b039fa@googlegroups.com>
 <49aa0134-a3f9-43a6-9e7d-2b587e0816eb@googlegroups.com> <e3643bc8-5dbd-4bc2-b244-f5b2f2d8e55d@googlegroups.com>
 <d839ba49-82c6-4e4c-b599-14fb41bc2852@googlegroups.com>
 <CAGwyn-Pf1RcjdfN8WUmZys488zmjjDYkHZFOTcB47dX_oBdf6w@mail.gmail.com>
Subject: Re: [robolectric] Re: Setup for non-maven
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_34_22503726.1351630501794"

------=_Part_34_22503726.1351630501794
Content-Type: multipart/alternative; 
	boundary="----=_Part_35_28136530.1351630501794"

------=_Part_35_28136530.1351630501794
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I just saw that this thread is about non-maven projects. I am actually=20
using maven.
Does this exception make more sense in a maven context? Perhaps some=20
configuration error in the pom?
I will put together a minimal example to reproduce this problem and post it=
=20
here later this week.

On Monday, October 29, 2012 2:54:55 PM UTC+1, Phil Goodwin wrote:
>
> I'll bet it's a classloader problem. The RobolectricTestRunner uses a=20
> special classloader to instrument all of the Android jars and then loads=
=20
> all of the tests along with a copy of itself in that classloader. After=
=20
> that it delegates all of the calls made to itself to its copy within the=
=20
> classloader via the RobolectricTestRunnerInterface. It appears that=20
> something has gone wrong with that mechanism. Is there more than one copy=
=20
> of Robolectric floating around by any chance?
>
> On Sun, Oct 28, 2012 at 9:56 AM, Thomas H <thomas.he...@googlemail.com<ja=
vascript:>
> > wrote:
>
>> Did you find a solution for this?
>> I have the same problem:
>>
>> java.lang.ClassCastException:=20
>> com.xtremelabs.robolectric.RobolectricTestRunner cannot be cast to=20
>> com.xtremelabs.robolectric.internal.RobolectricTestRunnerInterface
>>
>> Am Samstag, 16. Juni 2012 00:50:15 UTC+2 schrieb Leif Ashley:
>>
>>> I just found the same line, and it is 234. Below is my whole class, wit=
h=20
>>> some lines removed to protect the innocent. But we never get to the set=
up=20
>>> method anyway because the constructor fails to complete. I agree though=
,=20
>>> the class and structure looks fine, and I'm not sure why this would thr=
ow=20
>>> the cast exception.
>>>
>>> @RunWith(**RobolectricTestRunner.class)
>>> public class Test1 {
>>>
>>>
>>>     @Before
>>>     public void setUp() throws Exception {
>>>        ...
>>>     }
>>>
>>>     @Test
>>>     public void test() throws Exception {
>>>        ...
>>>     }
>>> }
>>>
>>> On Friday, June 15, 2012 6:44:38 PM UTC-4, Chuck Greb wrote:
>>>>
>>>> I have never seen this error before. It looks like it's coming from=20
>>>> this line but I'm not sure why. Are you using a custom test runner or =
class=20
>>>> loader?
>>>>
>>>> https://github.com/pivotal/**robolectric/blob/master/src/**
>>>> main/java/com/xtremelabs/**robolectric/**RobolectricTestRunner.java#**
>>>> L234<https://github.com/pivotal/robolectric/blob/master/src/main/java/=
com/xtremelabs/robolectric/RobolectricTestRunner.java#L234>
>>>>
>>>>
>>>> On Friday, June 15, 2012 6:28:31 PM UTC-4, Leif Ashley wrote:
>>>>>
>>>>> Thanks again... that gets me further along, but now I get:
>>>>>
>>>>> java.lang.RuntimeException: java.lang.ClassCastException:=20
>>>>> com.xtremelabs.robolectric.**RobolectricTestRunner cannot be cast to=
=20
>>>>> com.xtremelabs.robolectric.**internal.**RobolectricTestRunnerInterfac=
e
>>>>>
>>>>> It looks like the RobolectricTestRunner didn't implement the **Robole=
ctricTestRunnerInterface=20
>>>>> in this jar. Sound right to you?
>>>>>
>>>>>
>>>>> On Friday, June 15, 2012 6:24:21 PM UTC-4, Chuck Greb wrote:
>>>>>>
>>>>>> Highlight robolectric-1.2-**SNAPSHOT-jar-with-**dependencies.jar and=
=20
>>>>>> then from the bottom-right panel choose the "Artifact Information" t=
ab and=20
>>>>>> then you will see a button to Download.
>>>>>>
>>>>>>
>>>>>> On Friday, June 15, 2012 6:19:32 PM UTC-4, Leif Ashley wrote:
>>>>>>>
>>>>>>> Cool - I'll look at the starter. I have it somewhat running with a=
=20
>>>>>>> quick test setup of my own, but I think I'm missing dependencies. I=
 found=20
>>>>>>> this on their site:
>>>>>>>
>>>>>>> "If you=E2=80=99re not using Maven to build your project, you=E2=80=
=99ll probably=20
>>>>>>> want to grab the latest robolectric-X.X.X-jar-with-**dependencies.j=
ar=20
>>>>>>> from Sonatype<https://oss.sonatype.org/index.html#nexus-search;quic=
k~robolectric>
>>>>>>> "
>>>>>>>
>>>>>>> But for the life of me, I cannot figure out how to download the jar=
=20
>>>>>>> from Sonatype. lol
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Friday, June 15, 2012 6:13:12 PM UTC-4, Chuck Greb wrote:
>>>>>>>>
>>>>>>>> Using IntelliJ, you can either include Robolectric as a module=20
>>>>>>>> (source) or a library (jar). Robolectric should be added as a depe=
ndency to=20
>>>>>>>> your application module (above Android platform, scope TEST).
>>>>>>>>
>>>>>>>> You should setup the tests as Java/JUnit (not an Android project=
=20
>>>>>>>> test). Robolectric tests live inside the same module as your appli=
cation.=20
>>>>>>>> No emulator/device is required.
>>>>>>>>
>>>>>>>> Also, check out the AndroidIntelliJStarter project for a good=20
>>>>>>>> example of integration as a submodule.
>>>>>>>>
>>>>>>>> https://github.com/pivotal/**AndroidIntelliJStarter<https://github=
.com/pivotal/AndroidIntelliJStarter>
>>>>>>>>
>>>>>>>> Best,
>>>>>>>> Chuck
>>>>>>>>
>>>>>>>> On Friday, June 15, 2012 5:50:56 PM UTC-4, Leif Ashley wrote:
>>>>>>>>>
>>>>>>>>> I am wanting to use Robolectric in our development efforts and I'=
m=20
>>>>>>>>> a bit confused on a few points.
>>>>>>>>>
>>>>>>>>> The examples all show maven. However we are using Idea to run/tes=
t=20
>>>>>>>>> via the IDE launch and scripted ant scripts for test builds. What=
's the=20
>>>>>>>>> best method to unit test an android application with Robolectric =
in this=20
>>>>>>>>> senario? Do I create a separate java project or an Android test p=
roject?=20
>>>>>>>>> Personally, I want to have it just run as a local test (i.e. not =
running on=20
>>>>>>>>> a USB/simulator device).
>>>>>>>>>
>>>>>>>>
>
------=_Part_35_28136530.1351630501794
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

I just saw that this thread is about non-maven projects. I am actually usin=
g maven.<div>Does this exception make more sense in a maven context? Perhap=
s some configuration error in the pom?</div><div>I will put together a mini=
mal example to reproduce this problem and post it here later this week.</di=
v><div><div><br>On Monday, October 29, 2012 2:54:55 PM UTC+1, Phil Goodwin =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;">I'll bet it's a classloa=
der problem. The RobolectricTestRunner uses a special classloader to instru=
ment all of the Android jars and then loads all of the tests along with a c=
opy of itself in that classloader. After that it delegates all of the calls=
 made to itself to its copy within the classloader via the RobolectricTestR=
unnerInterface<wbr>. It appears that something has gone wrong with that mec=
hanism. Is there more than one copy of Robolectric floating around by any c=
hance?<br>

<br><div class=3D"gmail_quote">On Sun, Oct 28, 2012 at 9:56 AM, Thomas H <s=
pan dir=3D"ltr">&lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscate=
d-mailto=3D"jTYf5v8U_v8J">thomas.he...@<wbr>googlemail.com</a>&gt;</span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex">

Did you find a solution for this?<br>I have the same problem:<div><br>java.=
lang.ClassCastException: com.xtremelabs.robolectric.<wbr>RobolectricTestRun=
ner cannot be cast to com.xtremelabs.robolectric.<wbr>internal.<wbr>Robolec=
tricTestRunnerInterface<br>

<br></div>Am Samstag, 16. Juni 2012 00:50:15 UTC+2 schrieb Leif Ashley:<div=
><div><blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex=
;border-left:1px #ccc solid;padding-left:1ex">I just found the same line, a=
nd it is 234. Below is my whole class, with some lines removed to protect t=
he innocent. But we never get to the setup method anyway because the constr=
uctor fails to complete. I agree though, the class and structure looks fine=
, and I'm not sure why this would throw the cast exception.<div>

<br></div><div><div>@RunWith(<u></u>RobolectricTestRunner<wbr>.class)</div>=
<div>public class Test1 {</div><div><br></div><div><br></div><div>&nbsp; &n=
bsp; @Before</div><div>&nbsp; &nbsp; public void setUp() throws Exception {=
</div><div>&nbsp; &nbsp; &nbsp; &nbsp;...</div>

<div>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; @Test</div><div=
>&nbsp; &nbsp; public void test() throws Exception {</div><div>&nbsp; &nbsp=
; &nbsp; &nbsp;...</div><div>&nbsp; &nbsp; }</div><div>}</div><br>On Friday=
, June 15, 2012 6:44:38 PM UTC-4, Chuck Greb wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex">

I have never seen this error before. It looks like it's coming from this li=
ne but I'm not sure why. Are you using a custom test runner or class loader=
?<div><br></div><div><a href=3D"https://github.com/pivotal/robolectric/blob=
/master/src/main/java/com/xtremelabs/robolectric/RobolectricTestRunner.java=
#L234" target=3D"_blank">https://github.com/pivotal/<u></u>rob<wbr>olectric=
/blob/master/src/<u></u>main/<wbr>java/com/xtremelabs/<u></u>robolectri<wbr=
>c/<u></u>RobolectricTestRunner.java#<u></u>L<wbr>234</a></div>

<div><br></div><div><div><br>On Friday, June 15, 2012 6:28:31 PM UTC-4, Lei=
f Ashley wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-l=
eft:0.8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks again... that=
 gets me further along, but now I get:<div>

<br></div><div>java.lang.RuntimeException: java.lang.ClassCastException: co=
m.xtremelabs.robolectric.<u></u>Rob<wbr>olectricTestRunner cannot be cast t=
o com.xtremelabs.robolectric.<u></u>int<wbr>ernal.<u></u>RobolectricTestRun=
nerInt<wbr>erface</div>

<div><br></div><div>It looks like the&nbsp;RobolectricTestRunner didn't imp=
lement the&nbsp;<u></u>RobolectricTestRunnerInter<wbr>face in this jar. Sou=
nd right to you?</div><div><br><br>On Friday, June 15, 2012 6:24:21 PM UTC-=
4, Chuck Greb wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">

Highlight&nbsp;robolectric-1.2-<u></u>SNAP<wbr>SHOT-jar-with-<u></u>depende=
ncies.jar and then from the bottom-right panel choose the "Artifact Informa=
tion" tab and then you will see a button to Download.<div><br><br>On Friday=
, June 15, 2012 6:19:32 PM UTC-4, Leif Ashley wrote:<blockquote class=3D"gm=
ail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;p=
adding-left:1ex">

Cool - I'll look at the starter. I have it somewhat running with a quick te=
st setup of my own, but I think I'm missing dependencies. I found this on t=
heir site:<div><br></div><div>"<span style=3D"color:rgb(51,51,51);font-fami=
ly:helvetica,arial,sans-serif;font-size:14px;line-height:19px">If you=E2=80=
=99re not using Maven to build your project, you=E2=80=99ll probably want t=
o grab the latest robolectric-X.X.X-jar-with-<u></u>dep<wbr>endencies.jar f=
rom&nbsp;</span><a href=3D"https://oss.sonatype.org/index.html#nexus-search=
;quick~robolectric" style=3D"color:rgb(119,119,119);border-bottom-style:sol=
id;border-bottom-width:1px;border-bottom-color:rgb(204,204,204);font-family=
:helvetica,arial,sans-serif;font-size:14px;line-height:19px" target=3D"_bla=
nk">Sonatype</a>"</div>

<div><br></div><div>But for the life of me, I cannot figure out how to down=
load the jar from Sonatype. lol</div><div><br></div><div><br><br>On Friday,=
 June 15, 2012 6:13:12 PM UTC-4, Chuck Greb wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pad=
ding-left:1ex">

<div>Using IntelliJ, you can either include Robolectric as a module (source=
) or a library (jar).&nbsp;Robolectric should be added as a dependency to y=
our application module (above Android platform, scope TEST).<br></div><div>
<br>
</div><div>You should setup the tests as Java/JUnit (not an Android project=
 test). Robolectric tests live inside the same module as your application. =
No emulator/device is required.</div><div><div><div><br></div><div>Also, ch=
eck out the AndroidIntelliJStarter project for a good example of integratio=
n as a submodule.<br>

</div><div><br></div><div><a href=3D"https://github.com/pivotal/AndroidInte=
lliJStarter" target=3D"_blank">https://github.com/pivotal/<u></u>And<wbr>ro=
idIntelliJStarter</a></div><div><br></div><div>Best,</div><div>Chuck<br><br=
>On Friday, June 15, 2012 5:50:56 PM UTC-4, Leif Ashley wrote:<blockquote c=
lass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #c=
cc solid;padding-left:1ex">

I am wanting to use Robolectric in our development efforts and I'm a bit co=
nfused on a few points.<div><br></div><div>The examples all show maven. How=
ever we are using Idea to run/test via the IDE launch and scripted ant scri=
pts for test builds. What's the best method to unit test an android applica=
tion with Robolectric in this senario? Do I create a separate java project =
or an Android test project? Personally, I want to have it just run as a loc=
al test (i.e. not running on a USB/simulator device).</div>

</blockquote></div></div></div></blockquote></div></blockquote></div></bloc=
kquote></div></blockquote></div></div></blockquote></div></blockquote></div=
></div></blockquote></div><br>
</blockquote></div></div>
------=_Part_35_28136530.1351630501794--

------=_Part_34_22503726.1351630501794--