On 8 August 2010 22:34, James Carman <ja...@carmanconsulting.com> wrote: > To make sure I'm actually passing in the exact same values (by letting > the compiler create the arrays using the varargs feature) I added the > following output to the startsWithAny() method: > > System.out.println("startsWithAny(): Received " + string + " input > with " + (searchStrings == null ? null : > Arrays.asList(searchStrings).toString()) + " input array"); > > When running the old version of the test code to the new version, > there was no difference in the output. > > I also ran a similar test by changing getCommonPrefix() method: > > System.out.println("getCommonPrefix(): Received " + (strs == null ? > null : Arrays.asList(strs).toString()) + " input array"); > > Again, no changes in the output. So, we're at least exercising the > "guts" of the methods the same. Now I can understand that you might > be saying that we're not exercising how the code is called the same > way in both cases, but the varargs support vs. the manual array > creation is identical. If you think we should add back in the manual > String[] stuff, I guess we could, but I really don't see much value in > it other than testing that varargs == manual String[]. >
Although the compiler changes varargs into String[] arrays, the two tests are not equivalent. Using varargs exclusively can hide bugs. For example, method(String, String[]) is not the same as method(String ...). > > On Sun, Aug 8, 2010 at 4:26 PM, James Carman <ja...@carmanconsulting.com> > wrote: >> On Sun, Aug 8, 2010 at 1:39 PM, sebb <seb...@gmail.com> wrote: >>>> + assertFalse(StringUtils.startsWithAny("abcxyz", null, "xyz", >>>> "abcd")); >>> >>> Most of the above changes seem wrong to me, as they change what is being >>> tested. >>> >>> By all means add tests for varargs, but surely the array tests need to >>> be kept as well? >>> >> >> How do they change what is being tested exactly? >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org