From: <Mat...@un...> - 2006-02-14 10:30:04
|
Hello, I've written a couple of tests for the assertSame and assertNotSame = methods in class Assert. Maybe they can be useful: @Test public void same() { Object o1 =3D new Object(); assertSame(o1, o1); } =09 @Test public void notSame() { Object o1 =3D new Object(); Object o2 =3D new Object(); assertNotSame(o1, o2); } =09 @Test(expected=3D AssertionError.class) public void objectsNotSame() { assertSame(new Object(), new Object()); } =09 @Test(expected=3D AssertionError.class) public void objectsAreSame() { Object o =3D new Object(); assertNotSame(o, o); } =09 @Test public void sameWithMessage() { try { assertSame("not same", "hello" , "good-bye"); } catch (AssertionError exception) { assertEquals("not same expected same:<hello> was not:<good-bye>", = exception.getMessage()); } } =09 @Test public void sameNullMessage() { try { assertSame("hello" , "good-bye"); } catch (AssertionError exception) { assertEquals("expected same:<hello> was not:<good-bye>", = exception.getMessage()); } } =09 @Test public void notSameWithMessage() { try { assertNotSame("not same", "hello" , "good-bye"); } catch (AssertionError exception) { assertEquals("not same expected not same", exception.getMessage()); } } =09 @Test public void notSameNullMessage() { try { assertNotSame("hello" , "good-bye"); } catch (AssertionError exception) { assertEquals("expected not same", exception.getMessage()); } } Btw: They all are green :) Freundliche Gr=FC=DFe / Best Regards / Avec mes meilleures salutations =A0 Matthias Schmidt Consultant =A0 mailto:mat...@un... =A0 Unilog Avinci - a LogicaCMG company Hamborner Sra=DFe 53 D-40472 D=FCsseldorf =A0 http://www.unilog-avinci.de=20 |