|
1 | 1 | package cucumber.api;
|
2 | 2 |
|
3 |
| -import cucumber.api.event.TestCaseFinished; |
4 |
| -import cucumber.api.event.TestCaseStarted; |
5 |
| -import cucumber.runner.EventBus; |
6 |
| -import cucumber.runtime.ScenarioImpl; |
7 |
| -import gherkin.events.PickleEvent; |
8 |
| -import gherkin.pickles.PickleLocation; |
9 | 3 | import gherkin.pickles.PickleTag;
|
10 | 4 |
|
11 | 5 | import java.util.List;
|
12 | 6 |
|
13 |
| -public class TestCase { |
14 |
| - private final PickleEvent pickleEvent; |
15 |
| - private final List<TestStep> testSteps; |
16 |
| - private final boolean dryRun; |
| 7 | +public interface TestCase { |
| 8 | + int getLine(); |
17 | 9 |
|
18 |
| - /** |
19 |
| - * Creates a new instance of a test case. |
20 |
| - * |
21 |
| - * @param testSteps of the test case |
22 |
| - * @param pickleEvent the pickle executed by this test case |
23 |
| - * @deprecated not part of the public api |
24 |
| - */ |
25 |
| - @Deprecated |
26 |
| - public TestCase(List<TestStep> testSteps, PickleEvent pickleEvent) { |
27 |
| - this(testSteps, pickleEvent, false); |
28 |
| - } |
| 10 | + String getName(); |
29 | 11 |
|
30 |
| - /** |
31 |
| - * Creates a new instance of a test case. |
32 |
| - * |
33 |
| - * @param testSteps of the test case |
34 |
| - * @param pickleEvent the pickle executed by this test case |
35 |
| - * @param dryRun skip execution of the test steps |
36 |
| - * @deprecated not part of the public api |
37 |
| - */ |
38 |
| - @Deprecated |
39 |
| - public TestCase(List<TestStep> testSteps, PickleEvent pickleEvent, boolean dryRun) { |
40 |
| - this.testSteps = testSteps; |
41 |
| - this.pickleEvent = pickleEvent; |
42 |
| - this.dryRun = dryRun; |
43 |
| - } |
| 12 | + String getScenarioDesignation(); |
44 | 13 |
|
45 |
| - /** |
46 |
| - * Executes the test case. |
47 |
| - * |
48 |
| - * @param bus to which events should be broadcast |
49 |
| - * @deprecated not part of the public api |
50 |
| - */ |
51 |
| - @Deprecated |
52 |
| - public void run(EventBus bus) { |
53 |
| - boolean skipNextStep = this.dryRun; |
54 |
| - Long startTime = bus.getTime(); |
55 |
| - bus.send(new TestCaseStarted(startTime, this)); |
56 |
| - ScenarioImpl scenarioResult = new ScenarioImpl(bus, pickleEvent); |
57 |
| - for (TestStep step : testSteps) { |
58 |
| - Result stepResult = step.run(bus, pickleEvent.pickle.getLanguage(), scenarioResult, skipNextStep); |
59 |
| - if (!stepResult.is(Result.Type.PASSED)) { |
60 |
| - skipNextStep = true; |
61 |
| - } |
62 |
| - scenarioResult.add(stepResult); |
63 |
| - } |
64 |
| - Long stopTime = bus.getTime(); |
65 |
| - bus.send(new TestCaseFinished(stopTime, this, new Result(scenarioResult.getStatus(), stopTime - startTime, scenarioResult.getError()))); |
66 |
| - } |
| 14 | + List<PickleTag> getTags(); |
67 | 15 |
|
68 |
| - public List<TestStep> getTestSteps() { |
69 |
| - return testSteps; |
70 |
| - } |
| 16 | + List<TestStep> getTestSteps(); |
71 | 17 |
|
72 |
| - public String getName() { |
73 |
| - return pickleEvent.pickle.getName(); |
74 |
| - } |
75 |
| - |
76 |
| - public String getScenarioDesignation() { |
77 |
| - return fileColonLine(pickleEvent.pickle.getLocations().get(0)) + " # " + getName(); |
78 |
| - } |
79 |
| - |
80 |
| - public String getUri() { |
81 |
| - return pickleEvent.uri; |
82 |
| - } |
83 |
| - |
84 |
| - public int getLine() { |
85 |
| - return pickleEvent.pickle.getLocations().get(0).getLine(); |
86 |
| - } |
87 |
| - |
88 |
| - private String fileColonLine(PickleLocation location) { |
89 |
| - return pickleEvent.uri + ":" + location.getLine(); |
90 |
| - } |
91 |
| - |
92 |
| - public List<PickleTag> getTags() { |
93 |
| - return pickleEvent.pickle.getTags(); |
94 |
| - } |
| 18 | + String getUri(); |
95 | 19 | }
|
0 commit comments