Category: junit

  • How to test for the implementation of toString()

    Update: This entry has been crossposted to the transylvania-jug blog. Problem statement: you have some value objects for which you implemented toString() (for debugging purposes) and now you would like to test using a unit test that these implementations exist. Possible solutions: Use reflection to detect the existence of the method: boolean hasToStringViaReflection(Class clazz) {…