0

I want to create tests which are dependent on each other. That is the return value of one function (test case) should be used in other testcase.

I have tried using unittest and nose tests but unable to have functions which returns values and use them.

Are there any testing frameworks , which allow me to do so ?

UPDATE :

The test which i want to perform is as follows :

def setup():
 //Some initializations

def func(id):
    //some operations
     assert ' ' not in name

def test_mine:
    for loop of command line inputs 
         /////
         assert id > 0 
         if (some condition)
            for loop 
                yield func(id)

         else
            yield func(id)

So to be able to make func() a separate test case , i need to get the id which im unable to do

  • test's that depend on each, does not sound to me like `unit testing`... You can use mock objects to create inputs for small units that simulate what you want. – oz123 Mar 23 '14 at 03:48
  • 1
    I think which testing framework do you use doesn't matter. Please provide [Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve). – alecxe Mar 23 '14 at 03:49
  • @Oz123 : I need the value generated in one testcase to be passed to another . Will i be able to do that ? – user3291718 Mar 24 '14 at 05:21
  • @alecxe : Please see my update for the example – user3291718 Mar 24 '14 at 05:22

1 Answers1

0

In general, it's best to make tests as repeatable and rigid as possible (think functional programming), and as isolated as possible. You don't want side effects to outlast a test's teardown because they may affect the results of future tests. There may be tests where some randomness may be involved (tests involving thread serialization, for instance), but without further information, it's hard to give good, concrete advise.

However, let's say you have a method m1 which returns varying results for the same arguments, and depending on those return values, you wish to call and test either m2 and m3. You could easily put all of that within a single test case and condition assertions about m2 and m3 based on the return value of m1.

danielm
  • 101
  • 1
  • 1
  • I have updated my question with an example . I need separate testcases to distinguish between the tests performed. Is it possible to do so ? – user3291718 Mar 24 '14 at 05:26