Gil Zilberfeld explains the Primary bean annotation for using in integration tests.

Uncategorized

Integration Testing with Spring – Primary Beans

Injecting beans in Spring is very helpful in testing scenarios. You can run the same test with production code beans, and mocks.

Gil Zilberfeld explains how to organize Spring configurations for integration testing

intergation testsSpring

Integration Testing With Spring – Organizing Configurations

We’ve talked about nested configurations. Now, let’s move on to using imported configurations in a smart way. Let’s say in the main app (as in “production”), I have a whole lot of beans I need to inject. The thing not… Continue Reading…

Gil Zilberfeld discusses spring features for integration testing, this time nested configurations

Uncategorized

Integration Testing with Spring – Nested Configurations

Let’s dig deeper into configurations for integration tests in Spring. We’ll start with a nested integration context example, for a class (that might be a test class, because that’s our main focus). While we can use @Import, if we set up… Continue Reading…

Gil Zilberfeld explains about Spring features for testing and integration testing, this time with configurations

Spring

Integration Testing With Spring – Configurations

So how does Spring know what type to inject? Spring can do so in a different ways. The default is scanning any class in the class path. Spring tries to match the types it finds in the class path to… Continue Reading…

Gil Zilberfeld explains Spring testing features starting with dependency injection

Spring

Integration Testing With Spring – Dependency Injection

I want to take a step back and discuss what Spring and Spring Boot are what are the basics features we get out of the box, and how we can use them for our advantage. There’s a whole training I’ve… Continue Reading…

Gil Zilberfeld explains refactoring in legacy code, when using ApprovalTests and something unexpected happens

Refactoring

Refactoring Kung-Fu, Part VI

Ok, time to run the test. Well, that’s interesting. The test is not even running until the end, we’re crashing before it completes. Let’s see what’s wrong. Seems that this line breaks: List<Ingredient> fillingIngredients = new ArrayList<Ingredient>(ingredients.subList(1, ingredients.size() – 1));… Continue Reading…

Refactoring

Refactoring Kung-Fu, Part V

Last time we talked about flow analysis in the code. We figured out the cases we want covered. But, even for these cases, we don’t know what the expected result is. It’s worse than that in the real world. In our… Continue Reading…

Gil Zilberfeld explains about refactoring test cases in legacy code

legacy codeRefactoring

Refactoring Kung Fu – Part IV

The current code version we’re talking about is tag 1.1. Last time, we have surrounded our code with a boundary, doing some early refactoring. We now know the entry points, and the exits are covered by interfaces, leaving code we… Continue Reading…

Gil Zilberfeld explains refactoring for legacy code, about method extraction and constructor injection for refactoring legacy code

Refactoring

Refactoring Kung Fu: Part III

Check out the original version of the code (Java, and also in C#, in tag 1.0). Right, time to move some code around. Before we do that, remember step #1 in our process: Draw a line around our tested code.… Continue Reading…

Gil Zilberfeld explains the principles of refactoring legacy code

legacy codeRefactoring

Refactoring Kung Fu – Part II

Last time I gave you a sneak peak at our PastaMaker. You can check the whole project here. Let’s take a closer look. The main logic is in our PastaMaker, so focusing on testing it makes sense. Most of the… Continue Reading…