01: package com.canoo.webtest.reporting;
02:
03: import org.apache.tools.ant.Location;
04:
05: import com.canoo.webtest.ant.TestStepSequence;
06: import com.canoo.webtest.ant.WebtestTask;
07: import com.canoo.webtest.engine.Configuration;
08: import com.canoo.webtest.engine.StepFailedException;
09:
10: /**
11: * The root step result containing it's children results as well as some general information
12: * about the webtest. It is generated by the {@link StepExecutionListener}.
13: * @author Marc Guillemot
14: */
15: public class RootStepResult extends StepResult {
16: private final String fWebtestName;
17: private final String fWebtestDescription;
18: private final Location fWebtestLocation;
19: private final Configuration fConfiguration;
20: private StepResult fLastFailingTaskResult;
21:
22: private Throwable fException;
23:
24: public RootStepResult(final TestStepSequence step) {
25: super (step);
26: final WebtestTask webtest = step.getContext().getWebtest();
27: fWebtestName = webtest.getName();
28: fWebtestDescription = webtest.getDescription();
29: fWebtestLocation = webtest.getLocation();
30: fConfiguration = step.getContext().getConfig();
31: }
32:
33: public Configuration getConfig() {
34: return fConfiguration;
35: }
36:
37: /**
38: * Gets the description of the <webtest>
39: * @return the description
40: */
41: public String getWebtestDescription() {
42: return fWebtestDescription;
43: }
44:
45: public String getWebtestName() {
46: return fWebtestName;
47: }
48:
49: public Location getWebtestLocation() {
50: return fWebtestLocation;
51: }
52:
53: public boolean isError() {
54: return fException != null && !isFailure();
55: }
56:
57: public Throwable getException() {
58: return fException;
59: }
60:
61: public boolean isFailure() {
62: return StepFailedException
63: .isCausedByStepFailedException(fException);
64: // return fException instanceof StepFailedException;
65: }
66:
67: public boolean isSuccessful() {
68: return fException == null;
69: }
70:
71: /**
72: * Gets the result of the failing task (if any)
73: * @return <code>null</code> if the test is successfull.
74: */
75: public StepResult getFailingTaskResult() {
76: if (isSuccessful())
77: return null;
78: else
79: return fLastFailingTaskResult;
80: }
81:
82: protected void setLastFailingTaskResult(
83: final StepResult stepResult, final Throwable throwable) {
84: fLastFailingTaskResult = stepResult;
85: fException = throwable;
86: }
87: }
|