Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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?

Thanks.

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
    
add comment

2 Answers 2

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
2  
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
add comment

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
add comment

Your Answer

 
discard

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.