Tag: Tests
-
MagicMock with Python

MagicMock is an essential Python tool for testing, allowing developers to simulate external dependencies like databases and APIs, ensuring unit tests are fast and isolated. It provides flexible mock objects, enabling control over behavior and verification of interactions. Techniques like using the @patch decorator enhance its usability in tests.
-
Python Unittest Mocking Constructors

Writing effective unit tests can be challenging, especially with mocks. The post discusses issues with mocking constructors in Python’s unittest framework, suggesting that imports be structured differently to enable successful mocking. By importing the module instead of the class directly, the @patch decorator can function correctly, allowing for effective testing.
-
The Hardest Bug I’ve Faced

In this article, I will describe some of the worst bugs that happen in an application. Let’s start by splitting them into two main categories: those which I can reproduce on my laptop, and those I can’t reproduce on my laptop.
-
How to Use the Fluent Style to Easily Create a Dataset for My Unit Tests

When writing unit tests or integration tests, I have to create objects. Sometimes with a lot of mandatory fields. Instead of repeating this, instead of using utils methods, I use the Fluent style.
-
Unit Tests with Pytest

In this article I show how to write unit tests with Pytest. I show the parametrized tests, the conftest and the fixtures.
-
Tests Coverage with Jacoco, Unit and Integration Tests

In this article I show how to obtain the tests coverage with Jacoco, for both the unit and the integration tests. I show the configuration of the Surefire and Failsafe plugins to run the unit and integration tests separately. And finally I show how to use the Surefire and Failsafe plugins to feed Jacoco.
-
Random Values in the Unit Tests of Java with Podam

In this article I will show how to write random values in the unit tests of Java with Podam. Podam is a library to write random values in all the fields of an input object to the services to test.
-
Integration Tests in Spring Boot with MockMvc, DBUnit and H2

How to write integration tests in Spring Boot with MockMvc. Then, I show how to write tests in Spring Boot with DBUnit and H2 against a database.
-
Tests in Spring Boot with JUnit 5 and Mockito

In this article, I will configure the tests in Spring Boot with JUnit5 and Mockito. I will also write some unit tests with JUnit 5 and Mockito.
