Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

There is ambiguity in all papers I have read so I would like to ask about the following requirement:

Requirement: Being a Game master, I can access the GM menu by typing "menuInvoke".

Trying to do that as a regular player - is that a negative test or still positive in terms of verifying the requirement? Because some authors say negative testing means dealing with inputs unknown to specification, which would not be this case as the spec does say you need to be a Game master, implying it is not allowed for the other ones. However if you think like that, it is always implicit: range 1-1000 implies that nothing else can be entered, yet we test it as a negative test.

An example of ambiguity: Login system. Some say that providing incorrect password to receive Login error is negative test but I agree with the others - it is plain positive test as the requirement definitely specifies that only a user with valid password can login.

share|improve this question
3  
There are two cases here 1) When you enter a number, no message is displayed 2) If you enter a non-number it displays an error. You should write a test case for both of these. It doesn't matter which of these you label "positive" or "negative", just that you test both of them. –  CodesInChaos Mar 24 '13 at 10:18
    
@CodesInChaos Actually I cannot as we are required to classify tests as either negative or positive. Recently I started a discussion that resulted in discovery of contradictions in books and people' views. –  user970696 Mar 24 '13 at 11:26
1  
@user970696: you should ask the one who gave you that task what he means by "positive" or "negative". Is this homework? –  Doc Brown Mar 24 '13 at 18:42
    
@Doc Brown, no it is a company work.. We tend to follow standards but no book I have read and researched made clear distinction. It is either trivial (like range 1-100, so 1-100 is positive, anything outside is negative test case) or theoretical. But the example I posted is not that clear - or the negative is simply logging with any role different than GM and trying the command? –  user970696 Mar 24 '13 at 18:48
    
The example of testing that an incorrect password gets a login error would be a negative test (assuming there is a requirement saying this). The accepted answer (by nibra) confirms this, since an incorrect password would not belong to set D. –  Rogerio Aug 27 '13 at 21:35
add comment

2 Answers

up vote 4 down vote accepted

Look at your SUT as a function mapping values from a set D to values from a set V. As these values may be tupels as well, this view is valid for any function.

If you enter values from D into your function and test the result, it is a positive test. It may succeed (by getting the appropriate value from V) or fail (in any other case).

If you enter value, which is not from D, into your function and test the result, it is a negative test. It may succeed (by getting an error message) or fail (in any other case).

With these definitions (see Shivprasad Koirala. Sham Sheikh: Software Testing Interview Questions), a case can be constructed, where every possible input is valid. Think of a boolean function determining whether the input is an integer or not. Thus, the answer to the question "Do for all positive tests exist also negative ones?" clearly is: No.

For your example requirement, the function is probably

f: UserType X Command -> Action

In this case, both ('GameMaster', 'menuInvoke') and ('RegularPlayer', 'menuInvoke') are valid inputs, so the both test cases are positive tests.

On the other hand, it could be defined as

f: 'GameMaster' X Command -> Action

In this case, the tupel ('RegularPlayer', 'menuInvoke') is not a valid input, and testing this case would be a negative test.

Since your requirement does not contain the information needed to determine the kind of function, there is no general answer to the question regarding this requirement. This ambiguosity may be the reason, why examples in the literature either are so simple or contradicting.

share|improve this answer
    
Thank you, but it is still not that clear to me. Why the second case is not a valid input? Isnt it still just input that is processed differently, if regular player types that command because he just can type whatever he wants (e.g. it is a console)? –  user970696 Apr 4 '13 at 9:51
    
One more example here: Action can be done only on object X. When I try to perform the action on Y, this would a negative case, right? But hope you will react on my first comment. thanks –  user970696 Apr 4 '13 at 10:06
    
In the second case, the tupel ('RegularPlayer', 'menuInvoke') is not a valid input, because there the constant 'GameMaster' is the only valid value for the first parameter. What I tried to illustrate, that in some situations, it is your point of view (which most likely is reflected in the code) that makes a test positive or negative. What you said in your first comment, shows, that your understanding of the requirement is that stated in the first case. And that's fine. –  nibra Apr 4 '13 at 15:52
    
For your second comment: Again, it depends on the exact definition of action. Is it a function, that expects an object of type X as parameter, then yes, it is a negative test to throw in an object of type Y (give that Y is not derived from X). –  nibra Apr 4 '13 at 15:56
add comment

Positive Testing: To test the positive flow or happy flow of the application. Here the user's intention is to navigate to sunsequesnt screen or functionality without facing any error messages. Negative Testing: To test the invalid data handling, error messages verification.

share|improve this answer
    
how does this answer the question asked? –  gnat Aug 7 '13 at 11:50
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.