Re: [Watinfixture-users] Handling of empty strings
Status: Alpha
Brought to you by:
kalnir
|
From: Jeff P. <ka...@iw...> - 2007-09-21 04:28:58
|
Rob, You bring up a good point. Unfortunately, the answer isn't always simple. The problem is that string is a complex type, unlike ints, chars, and other base types. Since string is essentially an object, empty string and NULL are really two different unique values. In .NET, if you compared "" or string.Empty with null, they would not be equal. Null in general means the absence of a value - something that has not been initialized or set. For example, a Null coming back from a function could mean that there was nothing to return. An empty string, however, may be a valid return value from the same function - for example, from a database table. Also, an empty string may be a valid text response. For example, if you trim all alphabetic characters from the word "carrot" you would end up with an empty string, which in this case has a meaning. Depending on the context, empty string and Null may be able to be treated the same. But then also depending on context, empty string and Null may not be able to be treated the same. In this case, being consistent is the key. Whether verifying the selected value is blank, or checking the contents and finding a blank, both should be set up the same by the testers. Now, as far as ID and other fields go, the use of regular expressions was a necessity. ASP.NET generates very complex names, and it would be very painful if users had to type in those long names all the time. Instead, the regular expressions allow a shortened name to be used most of the time. But you're right, this does pose a risk as well. Names could end up with multiple matches if they are too similar. More than likely the tests will fail if more than one name is matched. This is very similar to your problem, where all the Name properties were the same. Indeed, a similar solution may be able to be applied to solve this problem. If CheckDropdownContents is handling multiple dropdowns of the same name, this is likely an unintentional by-product of how it was coded. I would have expected it to fail. Hopefully this helps to answer your questions. WatiNFixture is still a very young tool, and there is a long way to go before it becomes a mature utility for the everyday tester. Jeff -----Original Message----- From: wat...@li... [mailto:wat...@li...] On Behalf Of Rob MacFadyen Sent: Thursday, September 20, 2007 10:51 PM To: wat...@li... Subject: [Watinfixture-users] Handling of empty strings Hey all, I'm confused about handling of empty strings, especially as applied to dropdowns. For UserActions an empty string is just an empty string: |verify dropdown|x|has||selected| That passes if there is an empty string selected. However for CheckDropdownContents this is not the case. To pass the following must be used: !|WatiN.Contrib.WatiNFixture.CheckDropdownContents|x| |dropdownItem| |x1| |x2| |null| Also... the reporting will report an empty string as "blank"... shouldn't this be "null" (at least to be consistent within the CheckDropdownContents fixture)? So... I'm guessing shouldn't UserActions (et al) have the same handling for empty strings? Either || or |null| (or |blank|)? I'm also a bit confused. Are all ID specified as a regular expression? The CheckDropdownContents fixture clearly expects so... but I'm not sure about UserActions. What leaves me wondering is... what happens when there is more than one match? Looking at the code for UserActions.VerifyDropdownHasSelected it's unclear (doesn't look like it handles FindByID() returning multiple dropdowns). And looking at CheckDropdownContents I don't see it handling lists of dropdowns either... but it clearly does. So... I'm confused. Any suggestions on where I've gone off the rails? Regards, Rob ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Watinfixture-users mailing list Wat...@li... https://lists.sourceforge.net/lists/listinfo/watinfixture-users |