Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium Test Case vs. Test Suite vs. general usage

How do I know what should be a test case and what a test suite in Selenium? Is there any general rule for it? I've read the seleniumhq site any several others, but they only have some basic examples while I want to test a whole website.

My questions are for example:

  1. Say I'm testing some multi-step web form. Should I make it one test suite and each step (in web form) would be a single test case or all steps should be one test case?

  2. Say I've built a web forum and I want to test several features in it. Do I make one test suite and each test case tests each feature (or several cases per each feature) OR I'll have many test suites and each suite tests one feature with a few test cases.

  3. What to do if I have a form which contains 5 checkboxes - each of them can be obviously clicked or not. This may have some consequences when I submit the form. So - theoretically there are 2^5=32 possible execution flows. Should I test all 32? Or maybe should I just test each checkbox separately to simplify things. When can/should I simplify, when not? (assuming that checkboxes MAY be somehow related).

  4. Should each feature have test cases which test both positive and negative results? For example should I just focus on correct workflows - i.e. submit valid form and see if the website did what I asked for (worked) OR also submit empty form and check if error message appeared.

Can you answer these giving some practical examples (if needed)? - maybe using some (StackOverflow?) site as example site.

like image 234
wanson Avatar asked Feb 16 '12 13:02

wanson


1 Answers

Answer to 1 and 2:

I think this is more an issue about test design than selenium. Consider Selenium as a tool which controls the browser/website like a user would do. It simulates a user clicking through the page. To know what a test case is and what a test suite is you should think of the functionalities of your web application you want to test. Let's say you have web shop than one test case could test the following use case:

  • user puts articles in cart
  • user enters his data (name etc)
  • user gets a summary of his order
  • user confirms the order

It depends on your application which workflows or functionality you want to test. I would consider a test suite for a whole project so one suite for one web application. And this application has a lot of test cases. Every test case is a use case.

When building a test suite, consider some design patterns like ui-mapping, page object design and consider the advantages of a test management system (like TestNG in Java). here are some links to that:

  • http://www.shino.de/2011/07/26/on-the-pageobject-pattern/
  • http://www.theautomatedtester.co.uk/tutorials/selenium/page-object-pattern.htm
  • http://www.cheezyworld.com/2010/11/09/ui-tests-not-brittle/
  • http://hedleyproctor.com/2011/07/automating-selenium-testing-with-testng-ant-and-cruisecontrol/

Answer to 3 and 4:

It is similar to 1 and 2. It is always a question WHAT you want to test. Or a question what your project leader wants you to test (or customer). Every functionality which is important and should work should be tested.

like image 166
tester Avatar answered Nov 05 '22 02:11

tester