Blog
navigate_next
Java
Launching Instant Boilerplate for Junit tests
Shardul Lavekar
March 10, 2023

We saw that many developers needed help adding an agent, running their code with the agent, calling APIs, and generating perfect unit tests.

Our agent bytecode instruments the developer code and records the run time code execution. We use these recorded values in the generated unit tests. This helps in writing unit tests that cover real-world scenarios. 

Overall, just to generate a unit test - developers had to go through a lot of steps.

So, we came up with a version that generates an instant boilerplate for Junit tests. No agent addition or API calls are needed!

How does it work?

We figure out the syntax tree of the code. We traverse over the AST to identify what’s happening inside a method body. We look for any variables getting initialized or any methods being called - we keep a track of their type information too. We then simulate events synthetically and using those events, we create a boilerplate for unit tests.

What does it look like? 

All you have to do is, fill in these nulls/0s manually, and your unit test should work out of the box.

If you want to use recorded data with the agent, let us know and we can get in touch with you and set the agent up for you, on a call.

Shardul Lavekar
March 10, 2023
Use Unlogged to
mock instantly
record and replay methods
mock instantly
Install Plugin