Created
April 3, 2018 15:12
-
-
Save dassiorleando/e88aedb74a6682338631a8f30a0eaa37 to your computer and use it in GitHub Desktop.
Test class to illustrate the safe toString of an object: http://www.dassiorleando.xyz/safely-tostring-a-java-object
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void safeToStringTest() { | |
ObjectB objectB = new ObjectB("Fake propB"); | |
ObjectA objectA = new ObjectA("Fake propA", objectB); | |
String stringObjectA = Objects.toString(objectA); | |
System.out.println(stringObjectA); | |
assertNull(objectA.getObjectB2()); | |
assertTrue(stringObjectA.contains("objectB2=null")); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The main repo: https://github.com/dassiorleando/jse