.KnowHowTo.HaveSeveralObjectsUnderTest

.KnowHowTo.HaveSeveralObjectsUnderTest

Some storytests need to test through several different mechanisms, such as through both a web browser and a database. Others need to test several related objects. And there may be common actions that apply across many storytests.

FitLibrary supports these different scenarios by allowing for more than one object to be accessed in a storytest. Such access may be through the use of DoFixture, or may be direct to the object.

1. Using a second one temporarily

The primary DoFixture or object can have actions that provide access to related objects. Actions can then be carried out on such a related object in a single table.

Eg, in the following, for a Customer the first row of the second table retrieves some object and allows it to be changed and checked in that table (but not thereafter).

MyCustomer

select customerZi Breve

today is4 Jan 2012

select first payment on1 Jan 2012
mark payment as settled
date of settlementis4 Jan 2012

Notice that the Customer action returns the related Payment so that we can operate on that directly. If we used a separate DoFixture class to explicitly manage the Payment, we'd have to go to extra trouble to link the Payment back to the Customer.

2. Using two or more at the same time

FitLibrary allows more than one DoFixture to be active at the same time. Eg, here's a test that uses SpiderFixture for web browser testing and at the same time uses HttpClientFixture to carry out web service calls:

with spider

addfitlibrary.http.HttpClientFixtureashttp

get urlhttp://myTestSite.com/content

...

http gethttp://myTestSite.com/ws/customers

...

Any action of either SpiderFixture or HttpClientFixture can be used anywhere in the storytest.

3. Using two or more at the same time: where there's a clash of action name

If two fixtures have the same action name, and you want to use that action, it's necessary to specify which fixture is involved. This is done with a select, as shown below.

addfitlibrary.http.HttpClientFixtureashttp

addfitlibrary.spider.SpiderFixtureasspider

selectspider

get urlhttp://myTestSite.com/content

...

http gethttp://myTestSite.com/ws/customers

...

4. Common actions that apply across many storytests

It can be handy to have commons actions defined globally. For example, add this to the SuiteSetUp page:

add globalfitlibrary.specify.global.ExtraGlobal

An object of that is added as a global object to all storytests. So any of its actions are available anywhere in any storytest.

5. Scope

At any time, there may be several global objects and several storytest objects in scope throughout a storytest. In additon, in a particular table, further temporary objects may in scope at particular rows in a particular table.

In determining how to carry out an action in a storytest, these various objects are checked in the following order:
By default, FitLibrary starts with a standard global object, which provides various global actions, such as for file processing. This means that it's not necessary to have any fixture in a storytest.