Hack Week experiment: unit tests with claude#2922
Draft
Conversation
This error is also in the master branch, nothing new or introduced by Claude. Nevertheless, I asked it to fix it... and it came with an explanation and a fix that really didn't help.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DISCLAIMER: This is not intended for production. Claude.ai has not been audited by neither SUSE or the openSUSE project, so I have no intention to introduce any code generated by such a tool into any production-ready branch of the Agama repository.
Problem
Adapting the unit tests manually when we refactor the code takes a lot of time.
Experiment
During this Hack Week we want to explore how AI can speed-up the process. See https://hackweek.opensuse.org/projects/ai-powered-unit-test-automation-for-agama
This is a first rough experiment using the free version of Claude.ai. It includes the rationale applied by the tool as markdown files. It is written in Spanish because I used the web console (the only interaction method available for free) and my browser is configured to request pages in Spanish.
What I did was:
Asking Claude to adapt the current unit tests to the changes introduced in the code.
It did a great job. I tried it with 5 different test files and 3 of them worked out of the box. 2 of them needed trivial fixes (committed separately). The changes introduced make sense to me at first sight (I still have to review them carefully). It was not too intrusive, it respected the approach of the original tests. Although it decided to expand some parts.
Asking Claude to write a difficult test (LvmPage) from scratch.
At first sight, the test seems to be correct and very comprehensive (it even allowed me to fix a bug in the code). Claude shows very good understanding on what the component is supposed to do.
Initially the data of the mocks contained errors because Claude does not have full access to the
api-v2repo branch. But as soon as I gave it the correct type definitions it was able to fix those errors itself and produce a fully working test (except one minor fix that is 100% understandable).