Skip to content

Demo app that shows a concise way to do integration tests mixed with mocks in Spring Framework with JUnit and Mockito

License

Notifications You must be signed in to change notification settings

knes1/springmockedtests

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Integration Tests With Mocks

Reducing a bit of boilerplate in integration tests that contain mocks in Spring Framework using JUnit and Mockito

This is a demo/sample app to show an idea how to write concise integration tests in Spring Framework that include a mix of Spring managed beans and beans mocked with Mockito. Created for demo purposes for this article.

The most interesting stuff happens in UserServiceImplIntegrationTest. The classes used for simplified mocking are MockedBeans and MockImportRegistrar.

Aside from that, it shows how to create standalone console application with:

  • Spring Framework
  • JPA / Hibernate
  • Spring Data
  • Tested with JUnit and Mockito

I hope you find it useful! If you like this concept of mocking in integration tests, check out this repo that takes it a bit further and adds support for spies and other extras: https://github.com/hobo05/mockitobeans .

-- Kresimir

About

Demo app that shows a concise way to do integration tests mixed with mocks in Spring Framework with JUnit and Mockito

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages