Skip to content

Commit

Permalink
Use local class for test to avoid cross contamination
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Dec 13, 2023
1 parent d779feb commit 83ac527
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class GroovyMocks extends Specification {

then:
CannotCreateMockException e = thrown()
e.message == 'Cannot create mock for class java.util.ArrayList. The given type is already mocked by Spock.'
e.message == 'Cannot create mock for class org.spockframework.smoke.mock.GroovyMocks$LocalClassForMocking. The given type is already mocked by Spock.'

where:
[typeA, typeB] << ([['Mock', 'Stub', 'Spy']] * 2).combinations()
Expand All @@ -33,16 +33,18 @@ class GroovyMocks extends Specification {
void createMock(String type) {
switch (type) {
case 'Mock':
GroovyMock(global: true, ArrayList)
GroovyMock(global: true, LocalClassForMocking)
break
case 'Stub':
GroovyStub(global: true, ArrayList)
GroovyStub(global: true, LocalClassForMocking)
break
case 'Spy':
GroovySpy(global: true, ArrayList)
GroovySpy(global: true, LocalClassForMocking)
break
default:
throw new IllegalArgumentException(type)
}
}

class LocalClassForMocking {}
}

0 comments on commit 83ac527

Please sign in to comment.