Using OpenHands to Improve your Test Coverage

8 min read

Image from blog post

Written by

Tim O'Farrell

Published on

August 20, 2024

There is a lot of conjecture and abstract articles out there about what AI may or may not be able to do for you. There is also a lot of FUD about how it is going to replace everybody and crash the economy.

Here is a practical example of how OpenHands (Formerly OpenDevin) can improve your unit test coverage right now. We are constantly improving the reliability and usability of this tool, so your mileage may vary!

Background

I used an old side project for this: Json Urley. This project converts json objects to / from readable url parameters compatible with OpenAPI. The actual intent of this project is not that important for this article - I chose this project because:

  • It is quite small
  • The objective is well defined in the project README
  • It already uses linting and code coverage tools. The current coverage is 100% - every line of code is run by at least 1 test

The Sanity Check

I began by using some standard prompts - I am sanity checking here as I want to be sure that the project does what I expect at each step:

Please check out the repository https://github.com/tofarr/json-urley into the current workspace

Please describe what the json-urley project in the current workspace does

Please run the tests for this project

Now to do Something Useful!

I prompted the agent: Please create additional tests for this project - and it did! It created a new file with 8 additional unit tests.

Please create additional tests for this project

When I went to run this, 2 tests failed - so the agent automatically created a patch to fix the errors:

Please run tests for the json-urley project

Resolution

At this point I decided I needed to move over to github to see what was going on. I created a pull request including these changes. The first thing I noticed is my automatic checks failed - I guess I need to run black and check my tests...

Something is afoot...

It looks like the reason is the code snippet that the Agent wanted to merge into query_str_to_json_obj. The agent seems to have the impression that keys within the query string should be unique - and that is not the case!

The Agent assumed that keys must not repeat - this is not the case!

I removed this code snippet and the test_conflicting_types test case. That left me with 1 failing test - test_unicode_characters. This is a actually valid case that I missed, despite my best efforts with multiple passes and coverage being 100%!!! I had not considered how non English characters would be processed ("José" and "São Paulo"). Color me impressed. A small tweak and I am ready to merge the PR.

Conclusions

My colleague Graham has written a fantastic article describing levels of autonomy in automated systems. My practical take away is that at present, we still need a human in the mix, but that tools like OpenHands can make that human more productive and catch things they missed. AI agents will not fully replace human engineers (Yet!), but any of us that aren't using AI Agents will be soon - if only to catch our potential mistakes and make us more productive.

Citation
Using OpenHands to Improve your Test Coverage

Get useful insights in our blog

Insights and updates from the OpenHands team

Thank you for your submission!

Oops! Something went wrong while submitting the form.
Building the open standard for autonomous software development.

OpenHands is the foundation for secure, transparent, model-agnostic coding agents - empowering every software team to build faster with full control.

Build with SDK
Try it live
© 2025 OpenHands - All rights reserved