Re: [Shunit2-users] Bug in failSame, failNotSame and failNotEqual functions in shUnit2
Brought to you by:
sfsetse
From: Kate W. <kat...@fo...> - 2008-08-30 16:28:36
|
[+cc shu...@go...] Hi Mario, Honestly, you're the first to say much about it. I agree that it feels broke, and I've wondered exactly how to fix it. I modeled shUnit2 as close to JUnit 3.8.2 as I could. Looking at the code for failNotEquals() in JUnit, I see: static public void failNotEquals(String message, Object expected, Object actual) { fail(format(message, expected, actual)); } Looking at the code for fail(), I see: static public void fail(String message) { throw new AssertionFailedError(message); } And format(): static String format(String message, Object expected, Object actual) { String formatted= ""; if (message != null) formatted= message+" "; return formatted+"expected:<"+expected+"> but was:<"+actual+">"; } So, basically, it does absolutely nothing. Now, I don't disagree that this is the wrong approach, but I just haven't taken the time to really look into this. Looking at the patch you sent as part of the bug, it looks like a start to fixing the problem, but the unit tests fail with that patch. I'll update the bug at Google asking that you submit a new patch that fixes the unit tests as well. - kate On Wed, Aug 20, 2008 at 3:28 PM, Mario Sanchez Prada <msa...@ig...>wrote: > Hi all, > > First of all, congratulations for your work on shUnit2. I was really > impressed on how easy was to use it and how clean a testing suite is > thanks to your awesome script. I really like it a lot, sincerely, I was > looking for something like this all over the internet and it is exactly > what I needed, so thank you a lot :-) > > So, as I'm really happy, here you are my first contribution: > > As you could check out in the bugzilla... > > http://sourceforge.net/tracker/index.php?func=detail&aid=2062264&group_id=188001&atid=923569 > > ...I submitted today what I think it's a bug in the shUnit2 script, both > in its 2.0 and 2.1 versions. > > The bug is about failNotEqual, failSame and failNotSame functions being > probably wrong, since they always result on failures, regardless of the > parameters used being the the same or not. > > Perhaps I'm misunderstanding something (documentation is a bit confuse > as well about some of those three functions) so don't hesitate to > correct me if you think so. Nevertheless, according to how I think those > functions should work I attached a patch in the bugzilla with the fixes > I implemented in my local copy, which I'm using right now and seem to be > working right. Feel free to take a look into it and give me your > opinions). > > I'm also attaching a dummy test file I used to test the framework > provided by shUnit2, so you can check the bug out as well, in case you > wish to do it so. > > Hope it helps, > > Br, > > Mario > > ------------------------------------------------------------------------- > This SF.Net email is sponsored by the Moblin Your Move Developer's > challenge > Build the coolest Linux based applications with Moblin SDK & win great > prizes > Grand prize is a trip for two to an Open Source event anywhere in the world > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > _______________________________________________ > shunit2-users mailing list > shu...@li... > https://lists.sourceforge.net/lists/listinfo/shunit2-users > > -- Kate Ward <kat...@fo...> |