I’m trying to write some JUnit tests for an Android application.
I’ve read online that to have a unit test pass if it throws an exception, you would use the @Test annotation like this
@Test(expected = NullPointerException.class)
public void testNullValue() throws Throwable
{
Object o = null;
o.toString();
}
but Eclipse is telling me that this annotation doesn’t exist. How can I fix this? If I run the test, it runs fine and fails as expected but obviously I want it to fail (and thus actually pass) 🙂
You can always bypass it manually: