|
Mailing Lists
|
Home / Groups / CFUnit
Order of TestsWhat you are trying to do is pretty common. There are lots of things you can only test after you have done a lot of things to set up an environment where things make sense. But you have to do it all in one test case, making assertions along the way to make sure that everything is as it should be before you go to the next step. So you would write tests that look like this create a record run assertions on the create # of records before and after, primary key returned was as expected retrieve the record and run assertion on its values update the record retrieve and run assertions on its new values delete the record run assertions on # of records before after try to retrieve the record which should fail run assertions to be sure it did. The basic idea is that each test is a scenario that can test many assertions, and the test will fail and terminate as soon as one assertion fails. It is preferable that each test cover as little functionality as possible, but that is not alway possible. Its also preferable to avoid modifying the db in your tests, but sometimes it is unavoidable. David Harris wrote: > OK. > > I guess my logic would've been like this: > > testOne: > variables.someValue = "[some value]" > > testTwo: if strcutKeyExists( variables , "someValue") - run the test > else fail("required value wasn't made") > > Thanks for the help > > > >> No, each test starts with a clean slate. Otherwise you would haveso >> many dependencies in the later tests that you wouldn't know if they >> really failed or if something that went wrong in an earrlier test was >> the problem >> >> David Harris wrote: >> >>> Hi, >>> >>> I am in the process of setting up some tests, and have a situation where I would like to use the results of one test in another test. >>> >>> EG: >>> >>> testOne checks I can create a new instance of ABCComponent in the database, and the "create" function returns the key for that instance >>> >>> testTwo attempts to delete the instance created in testOne >>> >>> Is it possible to control the order of the tests to this level? >>> >>> Thanks >>> >>> David >>> >>> >>> >> > > |
February 12, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||