-
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.
feat!: automatic detected of mockable classes
* detect mockables classes automatically * major code cleanup BREAKING CHANGE: `@Mockable` changed in favor of automatic detection. Signed-off-by: Joke de Buhr <joke@xckk.de>
- Loading branch information
Showing
45 changed files
with
1,255 additions
and
439 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
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
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,26 @@ | ||
plugins { | ||
id 'java-platform' | ||
} | ||
|
||
javaPlatform { | ||
allowDependencies() | ||
} | ||
|
||
dependencies { | ||
|
||
api platform('org.apache.groovy:groovy-bom:4.0.6') | ||
api platform('org.spockframework:spock-bom:2.3-groovy-4.0') | ||
|
||
constraints { | ||
api 'com.google.auto.service:auto-service-annotations:1.0.1' | ||
api 'com.google.auto.service:auto-service:1.0.1' | ||
api 'com.google.dagger:dagger-compiler:2.44' | ||
api 'com.google.dagger:dagger:2.44' | ||
api 'com.google.errorprone:error_prone_core:2.13.1' | ||
api 'com.uber.nullaway:nullaway:0.9.6' | ||
api 'javax.inject:javax.inject:1' | ||
api 'org.jetbrains:annotations:23.0.0' | ||
api 'org.projectlombok:lombok:1.18.24' | ||
} | ||
|
||
} |
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
2 changes: 0 additions & 2 deletions
2
examples/kotlin/src/test/groovy/io/github/joke/spockmockable/tests/CompanyTest.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
54 changes: 54 additions & 0 deletions
54
examples/kotlin/src/test/groovy/io/github/joke/spockmockable/tests/MockableClassTest.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,54 @@ | ||
package io.github.joke.spockmockable.tests | ||
|
||
import org.spockframework.mock.MockUtil | ||
import spock.lang.Specification | ||
|
||
class MockableClassTest 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: | ||
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' | ||
} | ||
|
||
} |
2 changes: 0 additions & 2 deletions
2
examples/kotlin/src/test/groovy/io/github/joke/spockmockable/tests/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
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
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
4 changes: 1 addition & 3 deletions
4
...ests/PersonTestWithMockablePackage.groovy → .../joke/spockmockable/tests/MockTest.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
Oops, something went wrong.