I saw new Quick Start for Eclipse article at Robolectric Site and It
was very helpful.
I appreciate that.
I made new Projects and succeed the test given by you as following.
===================================================================
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
@Test
public void shouldHaveHappySmiles() throws Exception {
MyActivity activity = new MyActivity();
assertThat(activity.getResources().getString(R.string.hello),
equalTo("Hello World, MyActivity!"));
}
}
===================================================================
but when I add my own code to it as following, I got error message.
"java.lang.RuntimeException: no such layout layout/main" again.
===================================================================
@RunWith(RobolectricTestRunner.class)
public class MyActivityTest {
@Test
public void shouldHaveHappySmiles() throws Exception {
MyActivity activity = new MyActivity();
activity.onCreate(null); <---- added code.
assertThat(activity.getResources().getString(R.string.hello),
equalTo("Hello World, MyActivity!"));
}
}
===================================================================
I definitely need to use "activity.onCreate(null)" for my project.
If I don't call that function. I got "java.lang.RuntimeException: you
should have called setContentView() first" error message.
Please let me know how I can implement "activity.onCreate(null)" with
your given code without any errors.
Since you have posted sample code "activity.onCreate(null)" in it at
welcome page (
http://pivotal.github.com/robolectric/index.html), I can
suspect two things
(1) I am using "activity.onCreate(null)" in wrong way
(2) "activity.onCreate(null)" should meet some condition for its use
which i don't or you haven't told me yet.
Please help me out.
Thanks in advanced ~~~
P.S. I have completed setting with "Run Configuration" you told me
to.