-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: support for spock1.3-groovy2.4. fixes #112
- Loading branch information
Showing
12 changed files
with
201 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
id 'java' | ||
id 'groovy' | ||
} | ||
|
||
dependencies { | ||
testImplementation platform('org.codehaus.groovy:groovy-bom:2.5.15') | ||
testImplementation platform('org.spockframework:spock-bom:1.3-groovy-2.5') | ||
|
||
testImplementation project(':spock-mockable') | ||
testImplementation 'org.spockframework:spock-core' | ||
testImplementation 'org.objenesis:objenesis:3.2' | ||
testImplementation 'org.slf4j:slf4j-simple:1.7.32' | ||
} | ||
|
||
test { | ||
forkEvery 1 | ||
} |
35 changes: 35 additions & 0 deletions
35
examples/spock13-groovy25/src/main/java/io/github/joke/spockmockable/Person.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package io.github.joke.spockmockable; | ||
|
||
public final class Person { | ||
|
||
private String firstName = "John"; | ||
private String lastName = "Doe"; | ||
private final Address address = new Address("Murder Lane"); | ||
|
||
private Person() {} | ||
|
||
protected final String getFirstName() { | ||
return firstName; | ||
} | ||
|
||
private String getLastName() { | ||
return lastName; | ||
} | ||
|
||
private final Address getAddress() { | ||
return address; | ||
} | ||
|
||
private final static class Address { | ||
private final String street; | ||
|
||
private Address(final String street) { | ||
this.street = street; | ||
} | ||
|
||
public String getStreet() { | ||
return street; | ||
} | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
examples/spock13-groovy25/src/test/groovy/io/github/joke/spockmockable/PersonTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package io.github.joke.spockmockable | ||
|
||
import org.spockframework.mock.MockUtil | ||
import spock.lang.Specification | ||
|
||
@Mockable([Person, Person.Address]) | ||
class PersonTest extends Specification { | ||
|
||
def mockUtil = new MockUtil() | ||
|
||
def 'final from class is removed'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
expect: | ||
mockUtil.isMock person | ||
} | ||
|
||
def 'final from subclass is removed'() { | ||
setup: | ||
Person.Address address = Mock() | ||
|
||
expect: | ||
mockUtil.isMock address | ||
} | ||
|
||
def 'final from method is removed'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
when: | ||
def res = person.firstName | ||
|
||
then: | ||
1 * person.firstName >> 'Dorothy' | ||
|
||
expect: | ||
res == 'Dorothy' | ||
} | ||
|
||
def 'private on method is now protected'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
when: | ||
def res = person.lastName | ||
|
||
then: | ||
1 * person.lastName >> 'Gale' | ||
|
||
expect: | ||
res == 'Gale' | ||
} | ||
|
||
def 'final is removed and private on method is now protected'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
when: | ||
def res = person.address.street | ||
|
||
then: | ||
1 * person.address >> new Person.Address('Yellow Brick Road') | ||
|
||
expect: | ||
res == 'Yellow Brick Road' | ||
} | ||
|
||
} |
67 changes: 67 additions & 0 deletions
67
...13-groovy25/src/test/groovy/io/github/joke/spockmockable/PersonTestWithInheritance.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package io.github.joke.spockmockable | ||
|
||
import org.spockframework.mock.MockUtil | ||
|
||
class PersonTestWithInheritance extends TestBase { | ||
|
||
def mockUtil = new MockUtil() | ||
|
||
def 'final from class is removed'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
expect: | ||
mockUtil.isMock person | ||
} | ||
|
||
def 'final from subclass is removed'() { | ||
setup: | ||
Person.Address address = Mock() | ||
|
||
expect: | ||
mockUtil.isMock address | ||
} | ||
|
||
def 'final from method is removed'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
when: | ||
def res = person.firstName | ||
|
||
then: | ||
1 * person.firstName >> 'Dorothy' | ||
|
||
expect: | ||
res == 'Dorothy' | ||
} | ||
|
||
def 'private on method is now protected'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
when: | ||
def res = person.lastName | ||
|
||
then: | ||
1 * person.lastName >> 'Gale' | ||
|
||
expect: | ||
res == 'Gale' | ||
} | ||
|
||
def 'final is removed and private on method is now protected'() { | ||
setup: | ||
Person person = Mock() | ||
|
||
when: | ||
def res = person.address.street | ||
|
||
then: | ||
1 * person.address >> new Person.Address('Yellow Brick Road') | ||
|
||
expect: | ||
res == 'Yellow Brick Road' | ||
} | ||
|
||
} |
7 changes: 7 additions & 0 deletions
7
examples/spock13-groovy25/src/test/groovy/io/github/joke/spockmockable/TestBase.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.github.joke.spockmockable; | ||
|
||
import spock.lang.Specification; | ||
|
||
@Mockable([Person, Person.Address]) | ||
abstract class TestBase extends Specification { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
rootProject.name = 'spock-mockable' | ||
|
||
include 'examples:kotlin' | ||
include 'examples:spock13' | ||
include 'examples:spock13-groovy24' | ||
include 'examples:spock13-groovy25' | ||
include 'examples:spock20' | ||
include 'examples:spring' | ||
include 'spock-mockable' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters