DEV Community

Cover image for AI Powered unit testing ✨
Balaji Jayakumar
Balaji Jayakumar

Posted on • Updated on

AI Powered unit testing ✨

What I built

AI unit Tests Generator. This project uses Github actions to write unit-tests for your code.

Category Submission: Maintainer Must-Haves

App Link

https://github.com/killswitchh/ai-unit-test

Screenshots

Source Code
Source Code of addition.py

Generated AI Tests

Generated AI tests containing 3 test cases

Description

A Github action that uses GPT to generate unit-tests for your code

Link to Source Code

https://github.com/killswitchh/ai-unit-test

Permissive License

MIT License

Background (What made you decide to build this particular app? What inspired you?)

Open Source projects have a lot of intricate details and new features that are getting added frequently. Unit testing is a way to make sure that the features don't have any regression impacts and will encourage the developer to make large refactors without any fear.

This tool just makes that process a bit easier, whenever a branch is forked for a new feature, upon every push to the branch. This Github action will automatically write unit-tests for the added files.

So by the time the pull request gets generated to merge to main, it will have a set of AI generated unit-tests for the feature reducing developer's time to write these tests.

Here's a diagram to explain the flow.

Gitflow diagram

How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?)

I Used Github actions to run a python script that integrates with Open AI to generate unit-tests for the code files.
I learnt using Github actions and Open AI's library while building this. I was new to both of them.
The community submissions also inspired me a lot here!

Additional Resources/Info

I would like to thank the organizers for setting up and running this event. It is brining a lot of developers together and everyone is learning something new!

Top comments (0)