Albert Rosa It's not what you say it's how you say it

11May/120

Android Testing for Exception With Robolectric.

No Gravatar

I've been wanting to test runtime errors that I throw when certain criterias have not been met, Fairly easy to do with JUNIT itself but I found it difficult to use the expected annotation since when testing with Robolectric you receive a runtime exception first then drill into the cause of the exception.

here's how I found my way around this issue

@Test
public void testNullPointerWithURL() throws Exception{
try{
sample.execute();
fail("Should fail will Runtime Exception");
} catch (java.lang.RuntimeException e){
assertThat(e.getCause().getClass().getName(), CoreMatchers.is(NullPointerException.class.getName()));
}
}

 

sample.execute throws a NullPointerException. I wanted to validate in test that the exception was actually being executed.

 

Share
Filed under: Android, Testing No Comments
10Apr/120

#TNDO … Spartans 24/7/365

No Gravatar

Just how it should be...

Take No Days Off #TNDO Apparel Promo from Greyskale Multimedia LLC on Vimeo.

Share
Filed under: Personal, Race No Comments
9Apr/120

COLORADO… YOU READY… CUZ THE SPARTANS ARE TAKING OVER!

No Gravatar

That's right kids, Spartan Race is hitting Colorado. It's not just any spartan race it's the Spartan Military Race... Yours truly and My sister Will be taking on the course On May 5th... Cinco De Mayo.... TEAM Rice-N-Beans

Share
Filed under: Race, Spartan Race No Comments

Albert Rosa is using WP-Gravatar