MainActivity.java
mainactivity看起来像这样。国家的字符串值是从另一种方法getcountry获取的。
public class MainActivity {
String mCountry;
@Override
public void Country() {
String country = mCountry;
}
@Override
public void getCountry(String mCountry) {
this.mCountry = mCountry;
}
}
MainActivityTest.java
@Runwith(RobolectricTestRunner.class)
public void MainActivityTest(){
private MainActivity activity;
......
@Before
......
@After
......
...
@Test
public void countryTest(){
activity.country();
}
}
测试countryTest为mCountry产生空异常。...