Hi, at the moment I'm trying to test my android application using Robolectric 2.2. The app uses Android + Maven + RoboGuice + Volley etc.
The issue is the next one, i have some test which are working perfectly if i execute them individually through IDEA Intellij or using mvn . This tests are the unitary test of the different fragments contained into a main RoboFragmentActivity. My problem is that when I try to do “mvn clean install”, it start to run the tests, all together, and I get a JVM core dump like this:
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f7c4481be84, pid=12755, tid=140168581252864
#
# JRE version: 7.0_09-b05
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.5-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C6,1,com.example.client.ForeignProfileTest,testForeignProfilePresentationNotNull(com.example.client.ForeignProfileTest),null,null,null
[libpthread.so.0+0x9e84] pthread_mutex_lock+0x4
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/armando/git/orpheus-client/android-client/hs_err_pid12755.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
Aborted (core dumped)I can't understand why its not working all together because the tests work individually. Its not a memory leak, the app releases memory correctly.
I have heard that it could be related with Volley + Robolectric but I use Volley 1.0 and Robolectric 2.2, it suppose should work. Some posts that I saw too talks about the shadow objects that Robolectric do related with the callback generated by Volley. Im a little bit stuck with it.
Here is a example of test.
public class DiscoverFanTest extends CustomTestRunner {
@Inject
DiscoverFanView discoverFanView;
private Concert concert;
private List<Product> products;
Artist artist;
@Before
public void setUp() {
super.setUp();
artist = new PrototypeAlbums().getArtists().get(0);
discoverFanView.setArtist(artist);
concert = orpheusService.getConcert();
products = orpheusService.getProducts();
startFragment(discoverFanView);
}
@After
public void tearDown() {
TestGuiceModule.tearDown();
stopFragment(discoverFanView);
discoverFanView= null;
concert= null;
products= null;
artist= null;
}
@Test
public void testDiscoverFanPresentationNotNull() {
assert (new DiscoverFanPresentation(discoverFanView.getActivity().getApplicationContext(), discoverFanView) != null);
}
@Test
public void testDiscoverFanImageConcert() {
ImageView imageConcert = (ImageView) discoverFanView.getView()
.findViewById(R.id.imageComponentConcertImageView);
assert (imageConcert != null);
assertFalse(imageConcert.isClickable());
assert (imageConcert.getResources() != null);
assertTrue(imageConcert.getBackground() instanceof Drawable);
}
}And this is the CustomTestRunner
@RunWith(RobolectricTestRunner.class)
public class CustomTestRunner {
protected static NavigationView navigationView;
protected IService Service = new MockService();
protected static FragmentManager fragmentManager;
public void setUp() {
TestGuiceModule.setUp(this);
navigationView = Robolectric.buildActivity(navigationView.class).create().start().resume().get();
fragmentManager = navigationView.getSupportFragmentManager();
}
public void tearDown() {
TestGuiceModule.tearDown();
}
public void startFragment(Fragment fragment) {
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction = fragmentTransaction.show(fragment);
fragmentTransaction.add(fragment, null);
fragmentTransaction.commit();
}
public void stopFragment(Fragment fragment) {
if (fragment != null) {
fragmentManager.beginTransaction().remove(fragment).commit();
fragmentManager = null;
orpheusNavigationView = null;
}
}
}First of all thanks you, I hope someone could help me because i'm really obsess with it.
--
You received this message because you are subscribed to the Google Groups "Robolectric" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robolectric...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.