Use your agent, but be creative!
Test setup & macros
Currently, I am working on an app called gut-feeling. I have a backend written in Rust using the axum framework. To avoid shooting myself in the foot, I make sure I have a couple of integration tests for each API endpoint. Each integration test needs to do some repetitive work:
- Setup database
- Start webserver
- Teardown webserver
- Delete database
To not duplicate the code for this in every test, I created a macro for it. There are several types of macro's, so more precisely I used a procedural attribute macro. It's purpose is to inject code into my tests to cover the repetitive work. Ideally, I would refrain from injecting code through a macro, but because of rust's strict ownership and borrowing rules, I did not find a way to solve my problem with just test helpers or fixtures.
Here the two lines the macro injects:
let app = spawn_app_with_configuration(configuration).await;
// test body
// ...
// end test body
app.teardown().await;
But now I have developed a new feature where an API handles file uploads. The idea is that the user can upload photos which can later be used for some automation. As you might imagine, handling (and serving files) adds complexity to my whole application. To properly test this new feature I need to do something along the line of the following:
- Setup database
- Start webserver (with special parameters)
- Setup temporary directory (where user uploads are stored)
- Stop webserver
- Remove temporary directory
- Delete database
This sound very familar to what my first macro does with a few extras on top.
But macro code is complicated. It is not intuitive. It has weird syntax. At least for developers that are not on a senior level yet (of writing rust), things get messy quickly. And even worse, most of the code you write in the day is not written by yourself but rather by an LLM. At least for me that is currently the case, there are some who would disagree.
Challenging the LLM
But given the code was not written by yourself, how do you judge if that code is any good, how do you know what you are doing? How do you even understand what the code does? Usually after a feature is developed, I would challenge the LLM by asking it specific questions about chunks or lines of code, to guide me through them and explain the reason behind them. Sometimes that conversation leads to new insights for me (more often than I would like to admit) and sometimes it leads the LLM to rewrite parts of the code and straigthen out flaws. This works really well for me when I feel comfortable with the programming language, it's syntax and the topic I am working on. However when it comes to writing macros I start struggling a little bit. Is this how junior developers feel in the age of LLMs (or really anyone who just starts coding)? Maybe I was lucky to learn the craft before this big AI wave happened.
For the file upload macro for my test setup, I had a lot of questions. And it was a lot of code to parse through. My usual process of challenging the LLM was not working since I just see a lot of code in my terminal without proper text highlighting and the LLM trying to explain me (the dumb biological intelligence, just kidding) what is actually happening and why the code is good the way it is. Since I have written only a handful macros in my life, I lack experience and frankly expertise how good macros are structured and written. The syntax is just very different from regular Rust code or anything I am used to. So I need to inspect literally every line of the code written.
Finding new ways of working
LLMs are really good at creating any kind of document. The current models (GPT 5.5 and so on) are strong enough to write in almost any programming language, write .md files and html as well. Why not just create an interactive webpage that explains me the code?
GPT 5.5 one-shotted me the following page:
Well, to be honest it were 3 shots. The second shot was to add code highlighting to the code block. The third was to make it mobile friendly. But if you think about what it did in "just the first shot", that is crazy. This is work that would take an experienced developer a couple of hours at least. And here we got this page in under a minute.
I love that I can inspect any line of code, it even grouped the code in different sections and gave me a tool for highlighting. It even considered that one would like to move through the lines of code using the arrow keys. That for sure is something I would have forgotten on first draft.
LLMs have become very useful! But as always with LLM output, or things people say, stay critical and do not take every statement as a true fact.
Thanks for reading!