I'm pretty new to TDD. I see some docs says about positive test, negative test, boundary test etc. Can any one tell me the difference between a positive test and negative test? Is there any reference out there that says about the different types of tests? (I'm not looking for books)
Negative unit tests are useful for more than just making sure that every line of code is tested. Indeed, they're sometimes more important than positive tests. Negative tests demonstrate that your code properly handles invalid data, unexpected user input, and changes in other parts of the code base.
Positive unit tests are tests that return expected results when you present valid data to the tested code. Think of the classic calculator. A positive test for an addition method might execute with data points 2 and 3 while asserting the output is 5. This is a simplistic example, of course, but the idea is the same.
A positive test case tests that a system does what it is supposed to. Example: will allow you to login when valid credentials are supplied. A negative test case tests that a system does not do things it shouldn't. Example: should not allow you to login when invalid credentials are supplied.
Testing Technique used for Positive and Negative Testing:Boundary Value Analysis.
Positive Testing - testing the system by providing valid data.
Negative Testing - testing the system by providing invalid data.
For Example, an application contains a textbox and as per the user's Requirements the textbox should accept only Strings.By providing only String as input data to the textbox & to check whether its working properly or not means it is Positive Testing. If giving the input other than String means it is negative Testing..
Negative testing improves the testing coverage of your application. Using the negative and positive testing approaches together allows you to test your applications with any possible input data (both valid and invalid) and can help you make your application more stable and reliable.
Refer this Glossary for different type of tests
In terms of unit testing, (which is the focus of TDD) the concept can be described simply as follows:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With