A Modest first step in Test Generation

In the field of software development, code testing is a paramount task that should never be overlooked. At Berger-Levrault, we take this responsibility seriously and enforce a strict policy that includes the establishment of continuous integration (CI) and quality gates in our SonarQube server. Testing not only supports various developer activities, but also serves as a valuable source of documentation, describing the expected behavior of a system or its components.

As Berger-Levrault is currently migrating its applications using the Casino tool, we are often faced with the challenge of modernizing the front-end while preserving as much of the back-end as possible. However, this raises a crucial question: How do we ensure that the back-end behavior remains consistent during the migration process, especially when modifications are required?

To address this challenge, we are proud to introduce Modest, our innovative test generation tool designed with Evref and unveiled in March to our Business Units and Transverse Units. It is designed for non-regression testing using execution traces. In this blog post, we’ll delve deeper into Modest’s capabilities and demonstrate how it can revolutionize application test generation.

Using Modest as a user

Using Modest is made super simple. Modest comes as a black box in addition to a Java agent for your application. You only have to execute the following steps

  1. Start your application with the OpenTelemetry agent.
  2. Play with your application
  3. Run Modest (it will collect traces, analyze them, and generate tests)
  4. Integrate the tests in your application
  5. Run tests

A Deep Dive into Modest’s Steps and Requirements

Now, let’s explore the steps and requirements involved in Modest’s process.

Image display the steps of modest.
From codebase to code model
From codebase to traces
From traces to value model
value model and code model build a unit test model
finally unit test model generate unit test
Steps of Modest

Currently, Modest focuses on Java applications, generating Junit4 or Junit5 tests.

For instrumentation, we use OpenTelemetry (compatible with Dynatrace) and a custom agent. The agent consists of only four classes with minimal code that define the instrumented methods and, consequently, the methods for which tests are generated. Notably, our approach does not require any changes to the original codebase. In the case of Omaje, the instrumented methods are the service layer methods, which allows us to generate tests for all services and, thus, the entire Omaje back-end.

Modest then analyzes the codebase to produce a code model, which is a representation of the codebase that can be used for further analysis. To do so, the Modest tool is developed in Pharo, leveraging the Moose software analysis platform. This tool is already integral to many of our recent research projects and is part of Berger-Levrault’s significant contract with Inria. It enables easy source code analysis, code generation, and visualization to better understand codebases.

At the same time, Modest extracts a value model from the generated traces, using the serialized arguments and the returned value of each call, and links this value model with the code model. Based on both models, it builds a unit test model: the representation of the tests that should be generated to test your application.

Finally, it effortlessly generates unit test code and adds it to the codebase.

Example of a unit test generated by Modest

The generated unit tests follow the Arrange-Act-Assert pattern. The Arrange phase reconstructs the arguments and the returned value obtained from the trace. The Act phase executes the method under test with the same arguments. Finally, the Assert phase verifies that the actual return value matches the expected value from the trace.

Feedback and future work

Following the presentation of the Modest tool, we received valuable feedback from various teams, which has shaped our future work:

  • Further improve the generated tests by moving the setup part of tests to specific files for better test file management
  • Explore the use of Postman (a tool already used extensively by our teams) to create traces that can then be used to generate tests
  • Find an efficient way to package Modest for the production team, complete with configuration files for easy use

We’re also thrilled to share that the Omaje team has found the generated tests maintainable and readable. The next step is to fully integrate them into production by this summer.


With Modest, Berger-Levrault is taking a significant stride toward streamlining application migration and empowering developers to maintain high-quality code. We look forward to seeing the transformative impact Modest will have on our processes.

More ...

Retour en haut