DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Unit Testing Spring with Mockito & PowerMock

Unit Testing Spring with Mockito & PowerMock

Gordon Dickens user avatar by
Gordon Dickens
·
Oct. 25, 11 · Java Zone · Interview
Like (0)
Save
Tweet
10.35K Views

Join the DZone community and get the full member experience.

Join For Free

I’ve updated my Spring Mockito Demo app that I demonstrate when teaching with a PowerMock of a final class with a static method.

Demo Features

  • Maven 3.0
  • Maven Enforcer plugin restricting use of commons-logging, log4j, slf4j > 1.5, maven version range & java 1.6
  • All Maven plugin and java dependency versions are current and managed in properties of pom.xml
  • Maven Versions plugin for evaluating current configuration for any version updates of dependencies
    • mvn versions:display-dependency-updates scans dependencies and reports dependencies with newer versions
    • mvn versions:display-plugin-updates scans plugins and reports plugins with newer versions
    • To get the version changes w/o the ones that haven’t changed : mvn versions:display-dependency-updates | grep " -> "
  • Logback configuration with SLF4J
  • Mockito tests of the controller layer (services are mocked)
  • PowerMock configuration testing a final class with static method
  • All tests are true Unit tests, no use of Spring Context in tests, including the context creates integration tests

Code Repository

https://github.com/gordonad/core-spring-demos/tree/master/demos/mockitodemo

 

From http://gordondickens.com/wordpress/2011/10/22/unit-testing-spring-with-mockito-powermock/

unit test Mockito Spring Framework

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Fintech and AI: Ways Artificial Intelligence Is Used in Finance
  • Cloud-Based Integrations vs. On-Premise Models
  • Don't Underestimate Documentation
  • Counting Faster With Postgres

Comments

Java Partner Resources

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo