Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

In the interview, the employer asked me to write test cases or test scenarios to check the Palindrome of the word. I said one with positive test case and another with negative test cases. But employer was looking for more scenarios.

Can anyone think about more scenarios or test case???

Thanks in advance

share|improve this question
    
What automated testing and unit testing have in common with this question? –  dzieciou Jul 27 '12 at 16:53
    
Well... The actual question was to write unit testing using JUnit framwork for Palindrome checker. –  coolgokul Jul 27 '12 at 16:56
2  
See definition of palindrom at en.wikipedia.org/wiki/Palindrome and think about boundary cases. For instance, what happens to white spaces, and punctuation marks when compare input with its reversed form? Are they ignored or maybe even not acceptable? This is the task of a tester to explore those constrains. –  dzieciou Jul 27 '12 at 17:08
    
Great dzieciou...Thanks.. –  coolgokul Jul 27 '12 at 17:10
2  
Re: junit tests. Do you want readers to help you write unit tests or just get general test case scenarios? If only the latter, I would remove those tags from your question. –  dzieciou Jul 27 '12 at 17:12
show 2 more comments

3 Answers

Palindromes testing is very representative in terms of QA way of thinking. Moreover, writing tests dramatically increase the quality of task specification. When a QA engineer writes test cases, it well may happen that certain case is not covered in initial specs. This is a good reason for QA to come up with idea to improve those specs.

So, when you are asked for more test cases during an interview, they really want to make sure you think like a QA.

Let's see what test cases can be written. First, palindromes are based on strings, so you have to enforce common string testing:

  • Null string
  • Empty string - is it a palindrome? Probably not, but naive algorithm would return positive result.
  • Spacing and punctuation, as @dzieciou has noticed

Zero-width diacritic marks introduce several tests:

  • é (Latin small E with Acute Accent) can be represented in two ways, U+00E9 and U+0065 U+00B4, are they equal?
  • Naive reversing U+0065 U+00B4 would ruin the character, so it has to be tested as well;
  • Finally, can é and e be considered same character, in terms of palindrome?
share|improve this answer
add comment

Don't forget even and odd length strings.

Performance test.

share|improve this answer
    
Can you give an example implementation of a palindrom checking function, where even length strings are, by mistake, processed differently that odd length strings. Is it possible? –  dzieciou Jul 29 '12 at 6:53
1  
@dzieciou It depends on how a programming language rounds integer division results. Most round half up, so the coder would automatically use (str.length-1)/2 as upper margin for the for loop. (7-1)/2 == (6-1)/2 == 3 which is fine. The same code in C# will result (6-1)/2 == 2. –  bytebuster Jul 29 '12 at 8:25
    
@bytebuster My fault I was thinking of only one possible implementation (input == reverse(input)), while you probably assumed characters from a left half of a string are compared with characters on the right. From the original question it looks more like black box test. In such a case I should never assume only one possible implementation of the requirements. That's what I learned in general from this discussion. –  dzieciou Jul 29 '12 at 9:22
    
@dzieciou I agree this is very questionable whether or not pure tests of the implementation algorithm should be in QA responsibility in the real world. Maybe it is better if such test existed among unit tests (and was written by a coder). Nevertheless, you asked for a bad implementation, and here it is. :) –  bytebuster Jul 29 '12 at 14:01
add comment

See definition of palindrom and think about boundary cases.

For instance:

  • What happens to white spaces, and punctuation marks when comparing input with its reversed form? Are they ignored or maybe even not acceptable?

  • Is implementation case insensitive? Usually, both Anna and anna are considered palindroms.

This is the task of a tester to explore those constrains.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.