Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If you have three tests A,B,C and each tests a specific scenario, where B depends on A and C depends on B and A. How do you deal with that? Is it a case where there should not be three tests in the first place, but rather merged into one or are dependencies normal.

There are also situations where you have three tests A,B,C and each tests a different scenario but B includes test A and C includes test B and therefore test A. Is this normal or is this best avoided? If it is to be avoided, how should the tests be written?


share|improve this question
In what sense they depend on each other? Conceptually, setup in C is same as in A and B? Or assertions? Or physically, implementations of those tests share some code? Also, are doing test B after test A to save execution time? – dzieciou Nov 12 '13 at 17:49

Keeping each test separate, but dependent on each other, may introduce erroneous failures if the prerequisite tests have not completed or have failed. Each test should be independent of another.

I would cascade the tests in this example:

  • Test #1 = A
  • Test #2 = A + B
  • Test #3 = A + B + C
share|improve this answer
This is a reasonable approach, but as always, it depends. If you are in a time-critical situation, and the risk of finding bugs is low, it may be preferable to just execute Test #3 = A + B + C. – Joe Strazzere Nov 12 '13 at 19:03

It depends.

Some of the factors involved in deciding whether to try to make tests independent are:

  • Resources - if you have to run a very large number of functional and GUI automation tests (which is far from ideal, but is still something that happens), and you have limits on how much time or server resource you have available, performing the setup then running all the dependent tests in a series may be the most effective option you have.
  • Application complexity - the more complex the application, the more likely it is you will have to go through a large number of common steps to reach the function you actually want to test. For instance, you may be performing identical steps with users who have different privilege levels. Do you duplicate all the code or do you break it out and run it as dependent tests?
  • Tolerance for repeated code - Even if you break out common steps into their own routines, you'll still end up with a lot of repetition in the larger applications. For instance, you have two tests where you're logging in and creating orders for customer X. To make these independent, you need to include the log in and creation of customer X's account as well as the order in each test - that's a lot of duplication there. A change to the process flow can make a real mess of your tests before they hit the test you want - namely creating the order.
share|improve this answer

Your Answer


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.