Home » Tag Archives: Testing (page 16)

Tag Archives: Testing

Parameterized JUnit tests

junit-logo

Sometimes you encounter a problem that just screams for using “parameterized” tests rather than copy/pasting the same method many times.   The test method is basically the same and the only thing that changes is the data passed in.  In this case, consider creating a test case that utilitizes the ” Parameterized” class from JUnit. I recently ran into a ...

Read More »

The Test Waste Ratio

software-development-2-logo

Remember the days when bugs were just part of life? I mean a big part. If you recall those dark ages, we’ve spent most of our time fixing bugs and introducing others. In our spare time, we got to work on new stuff. Today is different, there are a lot less bugs. So we get to work more on the ...

Read More »

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 »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Advanced Java Guide
  • Java Design Patterns
  • JMeter Tutorial
  • Java 8 Features Tutorial
  • JUnit Tutorial
  • JSF Programming Cookbook
  • Java Concurrency Essentials