Mock Testing Roundup
There is virtually no way to get around mock testing in Java these days. When testing services its intricately important to test JUST that one service. In this presentation we will go over 3 popular frameworks EasyMock, JMock, and JMockit to show how to use mock testing.
When testing a service it is important to only test THAT service (at least for unit testing) You want to essentially test your service against various scenarios and outcomes. More often than not these scenarios occur due to different data being sent and returned from outside services and how your service interacts with that data. This can be hard to test for normally, however with mocks we can essentially mock out the calls to these services. We define in our test case what we expect that outside service to receive (parameter wise) and what data to pass back. This allows us to test that our service is performing with that data as expected.
We will look at three different popular mock frameworks out there: EasyMock, JMock, and JMockit to perform our testing with. We will see how each of these handle mocking different and which you may prefer for your needs.
About Joseph Nusairat
Joseph Faisal Nusairat, author of “Beginning JBoss Seam” and co-author “Beginning Groovy & Grails”, is a Java developer who has been working full time in the Columbus Ohio area since 1998, primarily focused on Java development. His career has taken him into a variety of Fortune 500 industries including military applications, data centers, banking, internet security, pharmaceuticals, and insurance. Joseph is particularly fond of open source projects and tries to use as much open source software as possible when working with clients. Joseph is a graduate of Ohio University with dual degrees in Computer Science and Microbiology with a minor in Chemistry. Currently, Joseph works as a Senior Partner at Integrallis Software (www.integrallis.com).
More About Joseph »