-
Notifications
You must be signed in to change notification settings - Fork 8
/
KarateHook.java
95 lines (84 loc) · 2.01 KB
/
KarateHook.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import com.intuit.karate.RuntimeHook;
import com.intuit.karate.Suite;
import com.intuit.karate.core.FeatureRuntime;
import com.intuit.karate.core.ScenarioRuntime;
import com.intuit.karate.core.Step;
import com.intuit.karate.core.StepResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class KarateHook implements RuntimeHook
{
private RPReporter rpReporter;
private static final Logger logger = LoggerFactory.getLogger(KarateHook.class);
public KarateHook()
{
this.rpReporter = new RPReporter();
}
@Override
public boolean beforeScenario(ScenarioRuntime sr)
{
return true;
}
@Override
public void afterScenario(ScenarioRuntime sr)
{
}
@Override
public boolean beforeFeature(FeatureRuntime fr)
{
try
{
this.rpReporter.startFeature(fr.feature);
}
catch (Exception e)
{
logger.error("beforeFeature exception: {}", e.getMessage(), e);
}
return true;
}
@Override
public void afterFeature(FeatureRuntime fr)
{
try
{
this.rpReporter.finishFeature(fr.result);
}
catch (Exception e)
{
logger.error("afterFeature exception: {}", e.getMessage(), e);
}
}
@Override
public void beforeSuite(Suite suite)
{
try
{
this.rpReporter.startLaunch();
}
catch (Exception e)
{
logger.error("beforeSuite exception: {}", e.getMessage(), e);
}
}
@Override
public void afterSuite(Suite suite)
{
try
{
this.rpReporter.finishLaunch(suite);
}
catch (Exception e)
{
logger.error("afterSuite exception: {}", e.getMessage(), e);
}
}
@Override
public boolean beforeStep(Step step, ScenarioRuntime sr)
{
return true;
}
@Override
public void afterStep(StepResult result, ScenarioRuntime sr)
{
}
}