Category Archives: Java

Spike: Unit Testing Static Methods

Previously we began discussing how great it is to use mocks and stubs. We showed how you can use dependency injection to set a stubbed out service instead of the real one. We also reviewed how you can use mocks to verify methods were acted upon from withing the method under test.  However you may come along a scenario where you need to test a method that requires you to call a static method on some other object. Regular mocking won’t suffice. Now it’s time for PowerMock

PowerMock is a nice add on to Mockito (and others) that supercharges what you can do with your tests. Continue reading


Coffee Notes: Spring & JUnit – What you Don’t Know

Over on Technophile Blog, Gordon Dickens posted a couple notes on Spring and Junit. With examples and comments Gordon review 2 features in Spring. One dealing with Default Context files and the second area is spring aware context files.
Gordon discusses:

1 Default Searching of Context File(s)
1a. No File Specified
1b. File specified (without a starting Slash)
1c. File specified with a Starting Slash
1d. Multiple Files

2. Spring Aware Test Options
2a. Autowiring Beans
2b. Transactional Test Methods
2c. Profiles – Evaluating Environment
2d. Timeout, Repeating & Invalidating Context

Nice features and easy to follow examples. Head over to Technophile Blog for the full story

http://gordondickens.com/wordpress/2011/01/07/junit-spring-what-you-dont-know-about/


Code Koans, Katas and Dojos

Developer groups are fantastic ways to enhance and hone your skills. Most of the user groups I’ve been to are great. Typically have good turnout, good presentations etc. Then there are developer conferences like No Fluff Just Stuff, Code Mash and others. What I like about those events is that there seems to be more hands on or more detailed conversations. Developers seem to group up and dive into topics in more detail in random open-spaces meetings. Unfortunately these events are only once a year

Where can we find presentations on new materials and actually work with other developers on the topic to build and hone our skills.  I stumbled upon a few similar Ideas I’m really beginning to love.

First is this idea of a Koan. A Koan is a Zen Continue reading


Unit Testing with Stubs and Mocks

Unit testing focuses on testing only the logic in a particular component without exercising logic in any dependent objects. This is often difficult as code is inherently dependent on other code. Developers can utilize techniques such as dependency injection, stubs and mocks to decouple code and execute unit level testing, but first it helps to understand what these techniques are. Continue reading


Spike: Prototyping with HSQLDB

Spike: Prototyping with HSQLDB - Tutorial by Christopher GrantI like doing quick prototypes but often when I come back to the code after awhle I forget about the database. Maybe I’m on  anew system that dones’t have the right Database locally or maybe I forgot to save off the schemea. Either way, my code is nice and neat in SVN but my DB isn’t.

So to counter this I’ve been looking at in memory DBs like derby and HSQLDB. At first I wasn’t sure what I was getting into but now I love it. These tools make prototyping quick and easy with little code.

I whipped up a little dev spike and thought I’d share it with you all. Continue reading


Follow

Get every new post delivered to your Inbox.