Negative and Edge Test Cases
What are negative test cases and have you ever heard about edge test cases?
When no, then you should read this. In this blog entry I want to cover negative test cases on one hand and also edge test cases on the other hand. When designing test cases for a given scenario, we are usually thinking about test cases which should pass to be sure, that the given scenario was implemented correctly. But we should also think about test cases, which prove whether wrong data lead to errors or not.
Negative Test Cases
*Let´s look at a simple example:* The given requirement is: Before accessing the webpage, the user should enter an username and password. Only the correct username and password allows to access the menber area of the webpage.
The positive test case is easy to write:
Arrange: Goto the login page
Act: Enter a valid username and password
Assert: You are in the member area of the webpage
But shouldn´t you write also a negative test case in order to try to break the login procedure? How should the negative test case look like?
The negative test case for this given requirement:
Arrange: Goto the login page
Act: Enter a invalid username and password
Assert: You are on a error page, which shows you entered incorrect data
Better we should write 3 negative test cases:
1.
Arrange: Goto the login page
Act: Enter a valid username and an invalid password
Assert: You are on a error page, which shows you entered incorrect data: “Username or Password invalid”
2.
Arrange: Goto the login page
Act: Enter an invalid username and a valid password
Assert: You are on a error page, which shows you entered incorrect data: “Username or Password invalid”
3.
Arrange: Goto the login page
Act: Enter an invalid username and an invalid password
Assert: You are on a error page, which shows you entered incorrect data: “Username or Password invalid”
But what kind of data should you use for this negative test case? There are several method to find invalid data: Change one letter in a valid username and/or password or randomize username and/or password.
Edge Test Cases
Now we´ve learned about negative test cases but what are edge test cases?
Given a scenario, where you need to check, whether a valid number is entered. Possible numbers are 1 - 100
Edge Test cases would be:
0
1
100
101
So why edge? Yes you got it. 0 and 101 are already negative edge cases, 1 and 100 are positive edge cases.
When you add one additional number between 2 and 99, then you have an addional check.
This is often done, because you don´t want to for at least 100 numbers.
With only 4-5 test cases you can check whether the input field is working like intended.
A different name for edge test cases is often used: Boundary Test Cases.
This is synonym, as you check for boundaries.