Skip to content

Instantly share code, notes, and snippets.

@bmaggi
Created March 22, 2017 09:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bmaggi/66a5803f79fefb6f57db887a9d9cec4f to your computer and use it in GitHub Desktop.
Save bmaggi/66a5803f79fefb6f57db887a9d9cec4f to your computer and use it in GitHub Desktop.
A simple class test to prove that null is not an instance
import org.junit.Assert;
import org.junit.Test;
/**
* A simple class test to prove that null is not an instance
* (aka useless: test!= null && test instanceOf MyClass)
*
* @author Benoit Maggi
*/
public class InstanceOfTest {
@Test
public void testNotNull() {
String notNull = "";
Assert.assertTrue(notNull instanceof String);
}
@Test
public void testNull() {
String isNull = null;
Assert.assertFalse(isNull instanceof String);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment