File tree Expand file tree Collapse file tree 1 file changed +21
-3
lines changed
testng/src/main/java/io/cucumber/testng Expand file tree Collapse file tree 1 file changed +21
-3
lines changed Original file line number Diff line number Diff line change 1
1
package io .cucumber .testng ;
2
2
3
3
import io .cucumber .core .backend .ObjectFactory ;
4
+ import io .cucumber .core .logging .Logger ;
5
+ import io .cucumber .core .logging .LoggerFactory ;
4
6
import io .cucumber .core .options .CucumberOptionsAnnotationParser ;
5
7
import io .cucumber .core .snippets .SnippetType ;
6
8
9
+ import java .lang .annotation .Annotation ;
10
+
7
11
final class TestNGCucumberOptionsProvider implements CucumberOptionsAnnotationParser .OptionsProvider {
8
12
13
+ private static final Logger log = LoggerFactory .getLogger (TestNGCucumberOptionsProvider .class );
14
+
9
15
@ Override
10
16
public CucumberOptionsAnnotationParser .CucumberOptions getOptions (Class <?> clazz ) {
11
17
CucumberOptions annotation = clazz .getAnnotation (CucumberOptions .class );
12
- if (annotation == null ) {
13
- return null ;
18
+ if (annotation != null ) {
19
+ return new TestNGCucumberOptions (annotation );
20
+ }
21
+ warnWhenJUnitCucumberOptionsAreUsed (clazz );
22
+ return null ;
23
+ }
24
+
25
+ private static void warnWhenJUnitCucumberOptionsAreUsed (Class <?> clazz ) {
26
+ for (Annotation clazzAnnotation : clazz .getAnnotations ()) {
27
+ String name = clazzAnnotation .annotationType ().getName ();
28
+ if ("io.cucumber.junit.CucumberOptions" .equals (name )) {
29
+ log .warn (() -> "Ignoring options provided by " + name + " on " + clazz .getName () + ". " +
30
+ "It is recommend to use separate runner classes for JUnit and TestNG."
31
+ );
32
+ }
14
33
}
15
- return new TestNGCucumberOptions (annotation );
16
34
}
17
35
18
36
private static class TestNGCucumberOptions implements CucumberOptionsAnnotationParser .CucumberOptions {
You can’t perform that action at this time.
0 commit comments