12
12
import java .lang .reflect .Method ;
13
13
import java .util .List ;
14
14
15
+ import static io .cucumber .core .backend .HookDefinition .HookType .BEFORE ;
15
16
import static org .hamcrest .CoreMatchers .startsWith ;
16
17
import static org .hamcrest .MatcherAssert .assertThat ;
17
18
import static org .junit .jupiter .api .Assertions .assertThrows ;
@@ -39,7 +40,7 @@ public <T> T getInstance(Class<T> glueClass) {
39
40
@ Test
40
41
void can_create_with_no_argument () throws Throwable {
41
42
Method method = JavaHookDefinitionTest .class .getMethod ("no_arguments" );
42
- JavaHookDefinition definition = new JavaHookDefinition (method , "" , 0 , lookup );
43
+ JavaHookDefinition definition = new JavaHookDefinition (BEFORE , method , "" , 0 , lookup );
43
44
definition .execute (state );
44
45
assertTrue (invoked );
45
46
}
@@ -52,7 +53,7 @@ public void no_arguments() {
52
53
@ Test
53
54
void can_create_with_single_scenario_argument () throws Throwable {
54
55
Method method = JavaHookDefinitionTest .class .getMethod ("single_argument" , Scenario .class );
55
- JavaHookDefinition definition = new JavaHookDefinition (method , "" , 0 , lookup );
56
+ JavaHookDefinition definition = new JavaHookDefinition (BEFORE , method , "" , 0 , lookup );
56
57
definition .execute (state );
57
58
assertTrue (invoked );
58
59
}
@@ -67,7 +68,7 @@ void fails_if_hook_argument_is_not_scenario_result() throws NoSuchMethodExceptio
67
68
Method method = JavaHookDefinitionTest .class .getMethod ("invalid_parameter" , String .class );
68
69
InvalidMethodSignatureException exception = assertThrows (
69
70
InvalidMethodSignatureException .class ,
70
- () -> new JavaHookDefinition (method , "" , 0 , lookup ));
71
+ () -> new JavaHookDefinition (BEFORE , method , "" , 0 , lookup ));
71
72
assertThat (exception .getMessage (), startsWith ("" +
72
73
"A method annotated with Before, After, BeforeStep or AfterStep must have one of these signatures:\n " +
73
74
" * public void before_or_after(io.cucumber.java.Scenario scenario)\n " +
@@ -84,7 +85,7 @@ void fails_if_generic_hook_argument_is_not_scenario_result() throws NoSuchMethod
84
85
Method method = JavaHookDefinitionTest .class .getMethod ("invalid_generic_parameter" , List .class );
85
86
assertThrows (
86
87
InvalidMethodSignatureException .class ,
87
- () -> new JavaHookDefinition (method , "" , 0 , lookup ));
88
+ () -> new JavaHookDefinition (BEFORE , method , "" , 0 , lookup ));
88
89
}
89
90
90
91
public void invalid_generic_parameter (List <String > badType ) {
@@ -96,7 +97,7 @@ void fails_if_too_many_arguments() throws NoSuchMethodException {
96
97
Method method = JavaHookDefinitionTest .class .getMethod ("too_many_parameters" , Scenario .class , String .class );
97
98
assertThrows (
98
99
InvalidMethodSignatureException .class ,
99
- () -> new JavaHookDefinition (method , "" , 0 , lookup ));
100
+ () -> new JavaHookDefinition (BEFORE , method , "" , 0 , lookup ));
100
101
}
101
102
102
103
public void too_many_parameters (Scenario arg1 , String arg2 ) {
@@ -108,7 +109,7 @@ void fails_with_non_void_return_type() throws Throwable {
108
109
Method method = JavaHookDefinitionTest .class .getMethod ("string_return_type" );
109
110
InvalidMethodSignatureException exception = assertThrows (
110
111
InvalidMethodSignatureException .class ,
111
- () -> new JavaHookDefinition (method , "" , 0 , lookup ));
112
+ () -> new JavaHookDefinition (BEFORE , method , "" , 0 , lookup ));
112
113
assertThat (exception .getMessage (), startsWith ("" +
113
114
"A method annotated with Before, After, BeforeStep or AfterStep must have one of these signatures:\n " +
114
115
" * public void before_or_after(io.cucumber.java.Scenario scenario)\n " +
0 commit comments