The tales of a software developer
Latest posts
-
Power up your integration tests with Mock Server
What is Mock Server? Mock Server is a considerably useful tool when testing integrations against HTTP services. It is especially useful for integration tests. With Mock Server, it is possible to launch an HTTP server within our test suite and define how it should behave when receiving specific requests from a client application. Additionally, Mock Server is able to verify that the client is making the expected requests when a particular execution flow is being executed. In what scenarios is Mock Server useful? API First Development: If you are using the API First development methodology, Mock Server can be helpful...
-
Test containers with Spring Boot. Persistence layer integration testing
Nowadays, there is no doubt that the quality of software and its flexibility are directly linked to the ability to verify if it still works after a change, a refactor or a new functionality. Time and effort are dedicated developing automated tests for our applications in order to keep adapting to changes while making sure our software keeps doing what it was doing before. A technology that can help us considerably when verifying that our software works as expected is Test containers. Test containers is an open-source framework that allows us to deploy infrastructure dependencies of our application when running...
-
Java 21 service with virtual threads performance test
I’m back to share the results of a comparison I was curious about: comparing the scalability of a simple microservice developed with Spring Boot. The idea behind this exercise is to test how Virtual Threads (one of the most famous Java 21 new features) impact on service availability. The service will be responsible for providing a simple REST API to store, read, modify, and delete locations in a PostgreSQL database. The code is available in the GitHub repository spring-boot-location-api. In order to develop this microservice I’ve used the traditional technological stack of Spring Boot, with the Spring Web and Spring...
-
How to log SQL queries using Entity Framework 6 like in EF Core
Watching the SQL queries Entity Framework executes is quite useful when a slow query needs optimization. If you’re already using ASP.NET Core, you might have already noticed that the debugging stream already outputs these SQL queries for you. But, if you’re working with ASP.NET MVC or ASP.NET Web API projects, by default you won’t see the SQL queries executed by EF. Even though, there’s a very simple trick to be able to see the actual SQL. Simply add the following code in your DbContext constructor. Once this piece of code has been added, you will be able to see the...
-
Why properties are evil in C#
As many of you might already know, properties are a neat way to define getters and setters. Many languages, such as C#, Delphi, Javascript or PHP support them and they are first-class citizens in the .NET ecosystem. Although properties are a handy resource, some property implementations can turn out to be evil. Very evil. Let’s dive into them. Side-effects in property code Causing side-effects is the worst practice when using properties, and it’s more spread than it seems at first. What can we consider side-effects? Modifying a nested object state, making a database query that modifies database state or change...