I want to use assert obj != null : \"object cannot be null\" on Android device. The assert doesn\'t seem to work, so I searched online and I found this local so
Sharing my class which I use for assertions on Android, its simpler, has nice naming and very elegant because it allows you to write asserts like this:
Assert.that(obj!=null, "Object should not be null");
Here's the code for the class:
public class Assert {
public static void that(boolean condition, String message) {
if (!condition) {
throw new AssertionError(message);
}
}
}
Hope it helps!