Question

I am a newbie to testing field. I know that test cases are the conditions to fulfil any client requirements i.e. the test conditions we need to fulfil the requirements. I need some idea how to formally write a test case. Can anyone give me any idea of writing the test cases.

Assume an example of login page. i want to write the test case for a login screen. Please provide a pattern to do so.

Any other example is also favourable.

Was it helpful?

Solution

Hey.
BDD approach is also nice way to express behavior. Simple Given-When-Then lets you structure your idea. For example:

Scenario: Login as Admin  
Given: Login Page is loaded  
  And loginInput field is present  
  And loginPassword secure filed is present  
  And locinSubmit button is present  
When: User puts adminLoginName into loginName field  
  And User puts adminLoginPassword in loginPassword secure field  
  And User clicks loginSubmit button  
Then: LoginPage is closed  
 And MainPage is loaded  
 And AdminPanel is visible  

OTHER TIPS

Basically, in order to create tests and test cases you need a good requirements document (what you refer to as 'client requirements'). If these requirements are written correctly, writing tests will be a piece of cake.

In the requirements document, there should be shall and will statements. For example:

the login page shall block a user after 10 failed logins

This is a testable requirement and then you write a test that has a user login incorrectly 10 times and sees if he can login successfully on the 11th try. Obviously you would be more specific in the test procedure, but that is the general idea.

Your example of having a login page isn't a good requirement. To test that requirement, you would just have to show that the login page exists. You want to be writing tests for specific features of this login page.

Also, there are will statements in a requirements document. These may not be required features depending on how the requirements were written, so you may not have to make tests for your will statements.

Test cases preparation is for understanding purpose of your project after testing. The test cases document is useful for you to quick review about the bugs/the cases status information either that test case is passed/failed. Login Page: Assume the login page in website or any other Case1: What happens if you give valid Username and Invalid password Case2: Invalid Username and Valid Password Case3: Invalid Username and Invalid password Case4: Valid User name and Valid Password Case5: Empty User Name and Valid Password Case6: Valid Username and Empty Password.

I just happened to watch this video on TDD in VS2010 today and the example she gives is on testing a login page.

Here is a page with a brief overview over software testing and also a example of a table with test cases. Software Testing Tutorial

This table can be of course extended to your needs, e.g. you will need a column for the result and maybe one for a comment, maybe for the test case are some preconditions needed, then add another column for that.

Here is a description of how to document a bug. (You will need that when you do your test ;-) ) Software Testing - Contents of a Bug

Positive test cases. • Enter valid username and password. • Click on forgot password link and retrieve the password for the username. • Click on register link and fill out the form and register username and password. • Use enter button after typing correct username and password. • Use tab to navigate from username textbox to password textbox and then to login button. ..................................................................................

Negative test cases • Enter valid username and invalid password. • Enter valid password but invalid username. • Keep both field blank and hit enter or click login button. • Keep username blank and enter password. • Keep password blank and enter username. • Enter username and password wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top