Blog Archives

When you want to disable a slow running test

A quick one. The code for this is here on GitHub. When testing your software with automated unit tests, you want to be thorough to get code coverage and genuinely cover system behaviour, yet some of the things you want

Tagged with: , ,
Posted in Uncategorized

Concurrent Unit Tests

In general, my heart sinks when I think I may have to write some unit tests for threaded code. This can be fiendishly difficult, and the secret with it is not to test things too absolutely, as timings and orders

Tagged with: , ,
Posted in Uncategorized

Signalling between threads in Java

Various releases of Java have introduced more sophisticated concurrency patterns to Java. You don’t need to build your own thread pooling techniques, or queues between threads. However, for a lot of uses, the synchronized keyword is pretty much all you

Tagged with: , ,
Posted in Uncategorized

Mockito Chaining

Dynamic mocks are great. I believe it was Martin Fowler who first switched me onto them. What we should be testing is how an object interacts with its surroundings. Often this means setting it running and verifying that it made

Tagged with: , ,
Posted in Uncategorized

Allow me to assert something

Stories from the code review. You will sometimes find the most innocuous of lines of coding causing some surprises. Consider this assertion: Seems reasonable enough – the thing will fail the assertion if the result is not as expected. A

Tagged with: ,
Posted in Uncategorized

Back to the Code

After a lot of posts talking about Linux admin (why!?) I thought it was time to do a code review. From today’s job interview. What’s wrong with the following function? Seems like an innocuous bit of code, doesn’t it? Yet

Tagged with:
Posted in Uncategorized

Log4j2 Mocking with Mockito and JUnit

This is an update to the very helpful work done here. I too have needed to put my own appender into a unit test so I can see that the right things are being logged. Depending on the logging framework

Tagged with: , ,
Posted in Uncategorized