Skip to content

Commit db8eeaa

Browse files
committed
[Spring] Throw exception when step definitions are annotated with component
When step definitions are annotated with @component or other related annotations they can be picked up by springs class path scanning. This conflicts with cucumbers class path scanning and may result in multiple bean definitions for the same class. This problem is hard to understand and hard to trace. By making the problem explicit and providing a clear instruction on how to resolve this we can hopefully avoid future confusion. The current implementation only checks the a subset of all annotations. This will hopefully be sufficient. Closes #1225
1 parent aeec6ea commit db8eeaa

File tree

17 files changed

+152
-42
lines changed

17 files changed

+152
-42
lines changed

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
</dependency>
4242
<dependency>
4343
<groupId>org.mockito</groupId>
44-
<artifactId>mockito-all</artifactId>
44+
<artifactId>mockito-core</artifactId>
4545
<scope>test</scope>
4646
</dependency>
4747
<dependency>

gosu/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,5 @@
5353
<artifactId>junit</artifactId>
5454
<scope>test</scope>
5555
</dependency>
56-
<dependency>
57-
<groupId>org.mockito</groupId>
58-
<artifactId>mockito-all</artifactId>
59-
<scope>test</scope>
60-
</dependency>
6156
</dependencies>
6257
</project>

groovy/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</dependency>
4747
<dependency>
4848
<groupId>org.mockito</groupId>
49-
<artifactId>mockito-all</artifactId>
49+
<artifactId>mockito-core</artifactId>
5050
<scope>test</scope>
5151
</dependency>
5252
</dependencies>

guice/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,5 @@
4242
<artifactId>junit</artifactId>
4343
<scope>test</scope>
4444
</dependency>
45-
<dependency>
46-
<groupId>org.mockito</groupId>
47-
<artifactId>mockito-all</artifactId>
48-
<scope>test</scope>
49-
</dependency>
5045
</dependencies>
5146
</project>

java/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</dependency>
3030
<dependency>
3131
<groupId>org.mockito</groupId>
32-
<artifactId>mockito-all</artifactId>
32+
<artifactId>mockito-core</artifactId>
3333
<scope>test</scope>
3434
</dependency>
3535
</dependencies>

junit/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<dependency>
3535
<groupId>org.mockito</groupId>
36-
<artifactId>mockito-all</artifactId>
36+
<artifactId>mockito-core</artifactId>
3737
<scope>test</scope>
3838
</dependency>
3939
</dependencies>

jython/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@
3535
<artifactId>cucumber-junit</artifactId>
3636
<scope>test</scope>
3737
</dependency>
38-
<dependency>
39-
<groupId>org.mockito</groupId>
40-
<artifactId>mockito-all</artifactId>
41-
<scope>test</scope>
42-
</dependency>
4338
<dependency>
4439
<groupId>junit</groupId>
4540
<artifactId>junit</artifactId>

needle/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
</dependency>
4343
<dependency>
4444
<groupId>org.mockito</groupId>
45-
<artifactId>mockito-all</artifactId>
45+
<artifactId>mockito-core</artifactId>
4646
<scope>test</scope>
4747
</dependency>
4848
<dependency>

osgi/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,6 @@
3737
<artifactId>junit</artifactId>
3838
<scope>test</scope>
3939
</dependency>
40-
<dependency>
41-
<groupId>org.mockito</groupId>
42-
<artifactId>mockito-all</artifactId>
43-
<scope>test</scope>
44-
</dependency>
4540
<dependency>
4641
<groupId>org.osgi</groupId>
4742
<artifactId>org.osgi.core</artifactId>

pom.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<!-- TestNG 6.11 makes the tests of the testng module to fail -->
4545
<testng.version>6.10</testng.version>
4646
<junit.version>4.12</junit.version>
47+
<hamcrest.version>1.3</hamcrest.version>
4748
<jython.version>2.7.1</jython.version>
4849
<mockito.version>1.10.19</mockito.version>
4950
<selenium.version>3.5.2</selenium.version>
@@ -349,6 +350,11 @@
349350
<artifactId>junit</artifactId>
350351
<version>${junit.version}</version>
351352
</dependency>
353+
<dependency>
354+
<groupId>org.hamcrest</groupId>
355+
<artifactId>hamcrest-core</artifactId>
356+
<version>${hamcrest.version}</version>
357+
</dependency>
352358
<dependency>
353359
<groupId>org.testng</groupId>
354360
<artifactId>testng</artifactId>
@@ -359,15 +365,16 @@
359365
<artifactId>jython-standalone</artifactId>
360366
<version>${jython.version}</version>
361367
</dependency>
362-
<dependency>
363-
<groupId>org.mockito</groupId>
364-
<artifactId>mockito-all</artifactId>
365-
<version>${mockito.version}</version>
366-
</dependency>
367368
<dependency>
368369
<groupId>org.mockito</groupId>
369370
<artifactId>mockito-core</artifactId>
370371
<version>${mockito.version}</version>
372+
<exclusions>
373+
<exclusion>
374+
<groupId>org.hamcrest</groupId>
375+
<artifactId>hamcrest-core</artifactId>
376+
</exclusion>
377+
</exclusions>
371378
</dependency>
372379
<dependency>
373380
<groupId>org.jsoup</groupId>

0 commit comments

Comments
 (0)