I am trying to test the overridden toString() in groovy (I know it is trivial but that is what you get after reading kent beck's TDD book). I assertSame on the expected string and the actual
Here is the code block:
    @Test void testToString(){  
     def study = new Study(identifier:"default-study", OID:"S_DEFAULTS1", name:"Default Study") 
     def expected = "org.foo.oc.model.bar(OID:S_DEFAULTS1, name:Default Study, identifier:default-study)"   
     assertSame "Should be equal", expected, study.toString()
    }
   
Here is the stack trace for the failed test:
     junit.framework.AssertionFailedError: Should be equal expected same:org.foo.oc.model.bar(OID:S_DEFAULTS1, name:Default Study, identifier:default-study) was not:org.foo.oc.model.bar(OID:S_DEFAULTS1, name:Default Study, identifier:default-study)
        at junit.framework.Assert.fail(Assert.java:47)
        at junit.framework.Assert.failNotSame(Assert.java:273)
        at junit.framework.Assert.assertSame(Assert.java:236)
    
Just to add that assertEquals works well with the same parameters. I know it is no biggie but I want to understand why it fails.
Thanks
 
     
    