Created
March 25, 2015 08:00
-
-
Save derkork/45d7fba64b54a41608e1 to your computer and use it in GitHub Desktop.
Testing service implementations without creating a spring context.
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
class SomeServiceImplTest extends Specification { | |
SomeServiceImpl underTest | |
SomeDao someDao | |
SomeOtherService someOtherService | |
void setup() { | |
// create the instance under test | |
underTest = new SomeServiceImpl() | |
// mock all dependencies and inject them | |
someDao = Mock(SomeDao) | |
someOtherService = Mock(SomeOtherService) | |
underTest.someDao = someDao; | |
underTest.someOtherService = someOtherService | |
} | |
void "Test that save invokes the Dao"() { | |
when: | |
someService.save("SomeValue") | |
then: | |
1 * someDao.save("SomeValue") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment