While testing the code using jUnit, if I change the method name, then jUnit skips that method.
Below is my code
and this class extends from the above.
Here, if I change the method name from testParseMultipleLines() to TestParseMultipleLines(), then jUnit skips this method.
I wonder why it is accepting anything that starts only with test*** and NOT Test****.
I haven't declared anywhere that it should test methods that begin with test and NOT Test.
What parsing rules are you trying to apply? Split on a blank line or a comma? Or something more complicated? It's not immediately obvious just from the test cases what the full rules are supposed to be.
String.split() takes a regular expression, so you can use that to split on multiple characters.
My case is sometimes a user might forget to enter something in which case a logic based on String.split() should be used otherwise String Tokenizer should be used which will split it based on whitespaces.
I don't want to show something like "A field can't be left blank" error message to user, but need to continue with whatever a user has keyed in.
I'm new to jUnit so not aware of any special feature available in it.
But that's not the problem you've got here. The real difference between the two cases is not that a value is empty - it's that the first two use a space delimiter, and the last one uses a comma delimiter. Are you saying you want to break on either of them?
Both StringTokenizer and String.split() are capable of splitting on any characters you want, so there's no need to switch between them for different cases. The issue isn't with JUnit either.
StringTokenizer skips empty tokens, so two spaces together work the same as a single space (if you're splitting on whitespace). You could get the effect you want by creating a StringTokenizer with the returnDelims flag set to true (but then you'd have to make sure you skip the delimiters). But I'd suggest just sticking with String.split().