Home » Tag Archives: Testing (page 13)

Tag Archives: Testing

Why shouldn’t I test private methods?

software-development-2-logo

Newcomers to TDD ask some interesting questions, here’s one I was asked recently: testing private methods is bad, but why? How did we get here? If you’re trying to test private methods, you’re doing something wrong. You can’t get to TDD nirvana from here, you’re gonna have to go back. It all started with an innocuous little class with an innocuous ...

Read More »

Fast Remote Service Tests

java-interview-questions-answers

Testing code that interacts with remote services is often pretty hard. There are a lot of tradeoffs that influence what tests you can write and the amount of tests to write. Most of the times you have zero control over the data you get from the service, which makes assertions tough to say the least. A while ago I used ...

Read More »

Getting started with Mocking in Java using Mockito

mockito-logo

We all write unit tests but the challenge we face at times is that the unit under test might be dependent on other components. And configuring other components for unit testing is definitely an overkill. Instead we can make use of Mocks in place of the other components and continue with the unit testing. To show how one can use ...

Read More »

Write effective Unit tests

software-development-2-logo

Soon or later we all experienced the comfortable feeling of test green lights, assuring a non regression after a change on a critical component or right after a refactoring which impacted several internal interactions. It’s probably the main advantage of having a good test coverage over your project as part of a continuous integration build system: tests may not spot ...

Read More »

Manual testing sinful?

software-development-2-logo

One of the asides I made in “Programmers without TDD will be unemployable” which caused a bit of outrage in the testing community was my comment “Manual testing is a sin.” While I have been unfair to many testers, and somewhat simplistic, I still stand by the statement. Let me expand on why I still stand by the comment and ...

Read More »

Using Reflection for Testing

java-logo

I am working on a presentation about the ‘Single Responsibility Principle’, based on my previous post. It take most of my time. In the meantime, I want to share a sample code of how I use to test inner fields in my classes. I am doing it for a special case of testing, which is more of an integration test. ...

Read More »

Testing for expected exceptions in JUnit

junit-logo

Unit tests are used to verify that a piece of code operates as the developer expects it to. Sometimes, that means checking that the code throws expected exceptions too. JUnit is the standard for unit testing in Java and provides several mechanisms for verifying exceptions were thrown. This article explores the options and their relative merits.   Take the following ...

Read More »

Mock final class

mockito-logo

Foreword If you already read some other blog post about unusual mocking, you can skip prelude via this link. I was asked to put together examples how to mock Java constructs well know for their testability issues:         Mock private method Mock final method Mock final class Mock constructor Mock static method I am calling these techniques ...

Read More »

Use Mockito to mock autowired fields

mockito-logo

Dependency injection is very powerful feature of Inversion of Control containers like Spring and EJB. It is always good idea to encapsulate injected values into private fields. But encapsulation of autowired fields decreases testability. I like the way how Mockito solved this problem  to mock autowired fields. Will explain it on example. (This blog post expects that you are little ...

Read More »

More Units with MoreUnit

junit-logo

Just over a year ago I wrote a post about working with JUnit in Eclipse. One of the commenters recommended MoreUnit in order to increase testing efficiency even more. Giving it a try I was delighted and the plugin’s keyboard shortcuts were immediately memorized by my autonomic nervous system… Additionally after using MoreUnit for a while I recognized a slight ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close