VOOZH about

URL: https://thenewstack.io/make-your-dev-life-easier-by-generating-tests-with-codiumai/

⇱ Make Your Dev Life Easier by Generating Tests with CodiumAI - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2023-11-18 04:00:55
Make Your Dev Life Easier by Generating Tests with CodiumAI
AI / Software Development / Software Testing

Make Your Dev Life Easier by Generating Tests with CodiumAI

Many developers still claim they don’t like writing tests, so the idea of generating them using AI was always going to appeal. Meet CodiumAI.
Nov 18th, 2023 4:00am by David Eastman
👁 Featued image for: Make Your Dev Life Easier by Generating Tests with CodiumAI
Image via CodiumAI website
Many developers still claim they don’t like writing tests, so the idea of generating them using AI was always going to appeal. Of course, tests are not necessarily a secondary issue — with Test-driven development (TDD) you write the tests first. While it is a good thing every team should try, common practice sees the creation of a minimum viable product (MVP) first, and when there is some evidence this has a future, to then continue the project with full unit testing. I had not seen CodiumAI before, but as it has generated an easy-to-understand elevator pitch — “Generating meaningful tests for busy devs” — right on its front page, I’m immediately ready to give it a go. Clearly, they are trying to jump into the tool space opened up by OpenAI’s GPT models — indeed, it is “powered by GPT-3.5&4 & TestGPT-1”. CodiumAI’s implementation only works with Visual Studio Code and JetBrains for now; I’ll use the former. I find VSC a bit awkward, but at least it should be happy with C#, my preferred tipple. But I know JetBrains tools are extremely popular too. As a test example, I will use the very simple bank account class with three methods: withdraw, deposit and balance. Let us assume a simple account with no overdraft facility. We should already have a strong feeling for what we want to test for:
  • We cannot withdraw more money than we have.
  • If the input deposit or withdrawal value is zero, we should not proceed.
  • Neither the requested deposit or withdrawal amounts should be negative.
Our reasoning for these rules come from different places. The first test reflects the business rules of the account. The second test reflects that some expense is involved with using a real banking system system; so while zero may be a valid value, we should not make a call if this is the case. And the third rule is just a restriction on the input range — and that should be handled by using unsigned inputs. Back to Codium. On the marketplace page, it appears to prefer Python, JavaScript and TypeScript, but it also clearly shows a menu operation to generate examples for other languages. As usual, Visual Studio Code opens in a messy blizzard of windows, but I am able to proceed. I am asked to log into Github — which is the norm pretty much everywhere — by a small dialog note at the bottom of the screen: 👁 Image
After some authentication tango, I am in. At some point .NET was loaded in and I got it to create a simple console project. Here is the code:
public class BankAccount 
{ 
 private uint balance; 
 public string ShowBalance() => $"{CURRENCYSIGN}{balance}"; 
 private const string CURRENCYSIGN = "$"; 
 public void Deposit(uint funds) 
 { 
 balance = balance + funds; 
 Console.WriteLine($"{CURRENCYSIGN}{funds} deposited. Balance now {ShowBalance()}"); 
 } 

 public void Withdraw(uint funds) 
 { 
 if (funds > balance) throw new Exception($"Cannot withdraw {CURRENCYSIGN}{funds}, balance is {ShowBalance()}"); 
 balance = balance - funds; 
 Console.WriteLine($"{CURRENCYSIGN}{funds} withdrawn. Balance now {ShowBalance()}"); 
 } 

 static void Main(string[] args) 
 { 
 BankAccount ba = new BankAccount(); 
 try { 
 // Money in 
 ba.Deposit(20); 

 //Money out 
 ba.Withdraw(5); 

 //Too much ba.Withdraw(25); 
 } 
 catch (System.Exception ex) 
 { 
 Console.WriteLine($"Error {ex.Messag}"); 
 } 
 }
}

From the console, the main method tests give the expected results:
BankAccount> dotnet run
$20 deposited. Balance now $20
$5 withdrawn. Balance now $15
Error Cannot withdraw $25, balance is $15

Now this is not devilishly complex, and there will be no need for any mocking frameworks for example. However, what we are interested in is whether the tool presents usable tests at all. OK, we can now ask CodiumAI to produce tests. The prompt to do so was shown neatly just above the class: 👁 Image
First of all, the AI-generated a very acceptable English summary of the class:
It gives an English explanation for the three methods. It also generated “code suggestions”, and these were all sensible to some extent. For example, it suggested using decimal values instead of an unsigned int. I will leave the reader, if they are interested, to consider the pros and cons of that. This gives me confidence that the tests it generates will be good. And they are. The presentation is very nice. It generates some tests and summarizes other tests it could generate. First, the Happy Path: 👁 Image
Here are two of the generated Happy Path examples:
[Test] 
public void test_deposit() 
{ 
 BankAccount ba = new BankAccount(); 
 ba.Deposit(20); Assert.AreEqual("$20", ba.ShowBalance()); 
} 

[Test] 
public void test_withdraw_more_than_balance() 
{ 
 BankAccount ba = new BankAccount(); 
 Assert.Throws<Exception>(() => ba.Withdraw(25)); 
}
Technically, throwing an exception is not part of a “happy path”, but let’s face it — two years ago, I would have been surprised if an app even grokked what the “happy path” was. So, rejoice. Each test is nicely presented for consumption in your test framework: 👁 Image
OK, let’s look at the edge cases: 👁 Image
These deal with the zero unit withdrawals — this implies that I can extend these tests and my code to satisfy my need to check that callouts to real systems are not done if not required. Note that you can generate and regenerate a test as needed. Finally the “other” cases: 👁 Image
The one of interest here is the one that tests the maximum value — if we were not sure about using an unsigned integer, we would want to check on any regression cases concerning changes in the size of the account.

Conclusion

Looking at this tool in the context of available AI tools, I think it is a good example of AI helping with the grunt work of developer testing, while not doing anything too unexpected. When you build up a test framework, you will need set up and tear down methods, and supporting functions that might mean you can’t just drop generated tests directly into your code without alteration. But from my own testing, I would recommend trying CodiumAI out to see if it can be part of your work day. Well, give it a test run anyway.
TRENDING STORIES
David has been a London-based professional software developer with Oracle Corp. and British Telecom, and a consultant helping teams work in a more agile fashion. He wrote a book on UI design and has been writing technical articles ever since....
Read more from David Eastman
SHARE THIS STORY
TRENDING STORIES
TNS owner Insight Partners is an investor in: OpenAI.
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.