A screencast about Java Unit Testing. Shows how to verify mock objects using Mockito. http://www.canoo.com/blog for the full blog post. http://www.mockito.org to read the Mockito documentation.
@comincho Complex systems are complex. If you're getting lost in how many dependencies your classes have % how much coupling your classes have, then it's a design smell and you need to look at refactoring. Of course, sometimes you can't avoid it or the alternatives are worse than the problem. This is why I prefer acceptance tests or integration tests better than unit tests. They are less fragile (but harder to make repeatable and automated). Summary: refactor first, then go to integration tests.
@ogourment I tried uploading to YouTube several times and each time it gave me all this extra time at the end of the video. Locally the video did not have all this blank space. It's too bad it happened, but it's not worth spending several hours tracking down a fix. Sorry :(
Difficult involved in mocking is what I can mock. You can mock concrete classes or interfaces, but in a real system with many services around... I get lost in what things I can mock. For example, I have a service with a method like createArticle(anActor, aPublicOffer, aProvider) where anActor is an instance of Actor, aPublicOffer is an instance of PublicOffer with a lot of properties, and go on. Sooner or later I have to go to DB. That's where I get lost, how mock could help me?
@jbarzilai1984 ha, too funny. yeah, it's hard to get easymock out of my head after using it for over 3 years. I say Spock at one point too, which is a groovy framework.
@comincho Complex systems are complex. If you're getting lost in how many dependencies your classes have % how much coupling your classes have, then it's a design smell and you need to look at refactoring. Of course, sometimes you can't avoid it or the alternatives are worse than the problem. This is why I prefer acceptance tests or integration tests better than unit tests. They are less fragile (but harder to make repeatable and automated). Summary: refactor first, then go to integration tests.
HamletDRC 6 months ago
@ogourment I tried uploading to YouTube several times and each time it gave me all this extra time at the end of the video. Locally the video did not have all this blank space. It's too bad it happened, but it's not worth spending several hours tracking down a fix. Sorry :(
HamletDRC 6 months ago
Difficult involved in mocking is what I can mock. You can mock concrete classes or interfaces, but in a real system with many services around... I get lost in what things I can mock. For example, I have a service with a method like createArticle(anActor, aPublicOffer, aProvider) where anActor is an instance of Actor, aPublicOffer is an instance of PublicOffer with a lot of properties, and go on. Sooner or later I have to go to DB. That's where I get lost, how mock could help me?
comincho 6 months ago
The last 9 minutes are the video equivalent of "this page intentionally left blank"? :-)
ogourment 7 months ago
@jbarzilai1984 ha, too funny. yeah, it's hard to get easymock out of my head after using it for over 3 years. I say Spock at one point too, which is a groovy framework.
HamletDRC 1 year ago
Wow, you say EasyMock instead of Mockito 3-4 times in each video.
jbarzilai1984 1 year ago