开发者

Multiple fitnesse fixtures possible

Is it possible to use multiple fitnesse fixture classes in one testtable (a scriptable i.e.) as in something like the followin开发者_如何转开发g?

|script|FixtureClassOne,FixtureClassTwo|
|AMethodInFixtureClassOne|2|
|AMethodInFixtureClassTwo|2|


This is possible. You should load the fixture as a library. E.g.:

| import |
| my.fixtures.classpath |

| library |
| fixture 1 |
| another fixture |

| script |
| etc. |

No need to provide a fixture after the 'script' identifier anymore.

You do have to be aware that if the fixtures share non-unique method names you get into trouble


Objective: To have Multiple Fixtures associated with a single HTML Test Case

How: As you are working with fitnesses HTML Test case, you probably have at least a single fixture associated with it, which we will call default Fixture.

But in order to access another fixture (where control of execution passes to the other fixture), write a method in the default fixture class:

public Fixture run(String str) {
    try {
        Fixture fixture = Fixture.loadFixture(str);
        return fixture;
    } catch (Throwable e) {
        // put your error handling here
        e.printStackTrace();
    }
    return null;
}

From the Test case, pass the fully specified location with the project to the run() method. When the run() method returns the fixture to the HTML test case, it passes its execution via the new Fixture.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜