Blog
navigate_next
Technology
How does Unlogged Work?
Shardul Lavekar
January 11, 2023

Whenever I demo Unlogged, developers and engineering leaders are naturally curious to know how unlogged works.

So, let me explain it.

Unlogged works in 2 parts.

  1. Logging

When you add our agent to your application run config, we bytecode instrument your Java code. With this, we start logging everything happening with your code, in runtime.

For example, take the below code snippet.

Controller

Service Layer

Data Access Layer

When you hit your controller layer from Postman/Swagger or UI, our agent logs everything from the controller to the data access layer. 

These log files are stored on your local machine (in /Users/YOUR_HOME_DIRECTORY/.videobug/sessions folder) if you are using Unlogged on localhost.

 

  1. Generating

When you hit the scan button on the IntelliJ plugin, we go through the log files and present Test candidates for each method. These test candidates show input and return values for the method selected.

You can manually verify if the input + return parameters combination for each candidate is accurate and generate a unit test instantly. 

Here is the generated unit test for the above example:

This is a simple demo example just to show how Unlogged works. 

You can try generating unit tests on your own code base.

Here is a demo:

In my demos, I am often asked if we are using some generative AI to write unit tests or some ChatGPT integration. I will write a separate post about ChatGPT writing unit tests but for now, I want to explain how Unlogged works, with a simple example.

Shardul Lavekar
January 11, 2023
Use Unlogged to
mock instantly
record and replay methods
mock instantly
Download Plugin