Code coverage with AI

Rate this content
Bookmark
  • In this lightning demo I will showcase how Codium, a cutting-edge generative AI tool, is revolutionizing code integrity. We will demonstrate Codium's ability to generate useful Mocha tests, taken from a public repository and highlight the seamless integration. You can see Codium as it transforms complex test scenarios into actionable insights, propelling code coverage forward. Join us for an insightful peek into the future of automated testing where speed meets quality!

This talk has been presented at TestJS Summit 2023, check out the latest edition of this Tech Conference.

FAQ

Codium is a generative AI assistant that integrates into your IDE, such as VS Code or the JetBrains suite. It offers features like test generation, code explanation, and collaboration tools, including automated pull request and commit message generation.

PR Agent is an open source project by Codium that automates the creation of pull requests, commit messages, and PR reviews. It can be run as a GitHub action or self-hosted and connects with platforms like GitHub, GitLab, Bitbucket, Azure DevOps, and CodeCommit.

Codium can generate tests for specific lines of code or functions that are under-covered, as identified by code coverage metrics. This helps ensure more comprehensive testing and better code quality.

Yes, Codium can add documentation to tests by generating doc strings based on your prompts, which help explain what the test is doing and why it is necessary.

Codium can suggest code improvements and refactoring options. It provides diffs for proposed changes, which developers can either accept or reject, helping them to optimize and clean up their code efficiently.

Codium supports integration with several IDEs including Visual Studio Code (VS Code) and the JetBrains suite, catering to a wide range of development environments.

You can reach Jaap via Twitter or join the Codium AI community on their Discord channel, where Jaap can be contacted directly.

Yes, Codium provides a demo through screenshots within presentations, showcasing features like test generation and configuration options in the VS Code interface.

Jaap Brasser
Jaap Brasser
8 min
07 Dec, 2023

Comments

Sign in or register to post your comment.

Video Summary and Transcription

Codium is a generative AI assistant for software development that offers code explanation, test generation, and collaboration features. It can generate tests for a GraphQL API in VS Code, improve code coverage, and even document tests. Codium allows analyzing specific code lines, generating tests based on existing ones, and answering code-related questions. It can also provide suggestions for code improvement, help with code refactoring, and assist with writing commit messages.
Available in Español: Cobertura de código con IA

1. Introduction to Codium and Demo

Short description:

Hello, welcome everyone. I'm Jaap from the Netherlands, representing Codium. We offer a generative AI assistant that integrates with your IDE, providing test generation, code explanation, and collab features. Our open source project, PR Agent, automates commit messages, PR reviews, and descriptions. Let's dive into a demo of Codium's capabilities by generating tests for a GraphQL API in VS Code. We can configure the test framework, libraries, and the number of tests to generate. We can also add prompts and use existing tests as examples. With Codium, we can generate tests and even document them. Let's address code coverage for the Express REST API server using Codium.

Hello, welcome everyone. So my name is Jaap, and as you can probably tell, I'm not from around here. I'm based out of the Netherlands. A little bit about myself, about how you can connect to me, but let's get into it and talk about the awesome things we do at Codium and how we can make your life easier.

So what Codium offers is we are a generative AI assistant that integrates in your IDE. So there can either be a VS Code, can be the JetBrains suite, and it offers test generation, code explanation, some collab features like no longer having to write your own pull requests. And we also have an open source project that one's called PR Agent. So PR Agent also has that functionality. It's completely free to use. URL is listed there. And you can either run it as a GitHub action or self host it, can connect to three of them listed here, GitHub, GitLab, Bitbucket, but it also works with Azure DevOps, CodeCommit, and I'm forgetting some others. So if you don't like writing your own commit messages, doing your own PR reviews, and writing your descriptions, PR Agent is a nice open source tool that we have at Codium.

And with that, I'd like to go into a demo. And I opted for the easy approach, zero demo failure. So I'm just going to dive into a couple of screenshots here that show some of the capability we have. And in order to do so, we're going to take a look at this repository. So this Mocha repository with a bunch of demo applications. And we're going to take a look at this GraphQL API. And we're going to see if we can generate some tests with it and show what the interface looks like for Codium. So this is in VS Code. And as you can see, there's a number of things that we can configure here. So we can select the test framework, we can select additional libraries, we can set how many tests we want to generate, we can also add prompting. And if you already have existing tests, you can also give a reference test example that we can use as a baseline to generate those tests. So what we can see here is I've generated one test. And I thought, well, it would be nice if the test was also documented. So I give a prompt, add a doc string. And then we can see that it also added a doc string to the test. Next up, I ran the code coverage for this repository. And I identified that Express REST API server did not have enough code coverage. So let's take a look at how we can solve this using Codium.

2. Code Explanation and Test Generation

Short description:

Here's the code we're working with. Line numbers 16, 21, and 22 are not covered by code coverage. The code explanation provides a summary, example usage, and flow. Codium allows analyzing specific methods, functions, or lines. We can add more tests using existing tests as a reference. We can select appropriate behaviors and generate tests. We generated a test for the 404 error, which improved code coverage. Prompting Codium AI generated a test for the error code 500. We can regenerate results and use chat commands.

So here's the code that we're working with. I'll just go back one. We can also see the line numbers here. So we'll refer to that when we are looking at the source code. So we can see that line number 16, so the 404, was not covered with code coverage, according to code coverage. And also 21 and 22. So a server error was also not covered.

To get a better understanding of how we can generate these tests, we can take a look at the code explanation. So it gives a summary. It gives an example usage, and also the flow of how this piece of code works. So in this case, we're looking at a single file. But with Codium, you can also specify a specific method, a specific function, or a number of selected lines that you want to analyze or generate tests for or create doc strings for.

So next up, we can see the existing test. And what we're going to do, because we already have existing tests that cover the main part of the behavior, we're going to click the button that says, add more tests. So we will generate tests, and we will use the existing tests as a reference to generate those tests from. And we can see that we have a behavior analysis of this function. This is a pretty simple function. So not all these behaviors make complete sense, but that's the idea. You can select which ones you think are appropriate and then generate tests for those. Also have an option to generate the tests ourselves.

So in this case, we generated the one for the 404 error. And after adding that to the repository, rerunning the code coverage, we can see that now line number 16 is also covered. So great. There was no test, however, for the error code 500. And there was also no behavior for that. So I prompted Codium AI to generate the test for error code 500. And that way you can also generate those tests. And for any of the results that we generate, we can click regenerate to see what kind of to have it generate new code. We can do prompting to improve the code and to kind of guide it to the end goal. And we also have a number of chat commands integrated.

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Building a Voice-Enabled AI Assistant With Javascript
JSNation 2023JSNation 2023
21 min
Building a Voice-Enabled AI Assistant With Javascript
Top Content
This Talk discusses building a voice-activated AI assistant using web APIs and JavaScript. It covers using the Web Speech API for speech recognition and the speech synthesis API for text to speech. The speaker demonstrates how to communicate with the Open AI API and handle the response. The Talk also explores enabling speech recognition and addressing the user. The speaker concludes by mentioning the possibility of creating a product out of the project and using Tauri for native desktop-like experiences.
AI and Web Development: Hype or Reality
JSNation 2023JSNation 2023
24 min
AI and Web Development: Hype or Reality
Top Content
This talk explores the use of AI in web development, including tools like GitHub Copilot and Fig for CLI commands. AI can generate boilerplate code, provide context-aware solutions, and generate dummy data. It can also assist with CSS selectors and regexes, and be integrated into applications. AI is used to enhance the podcast experience by transcribing episodes and providing JSON data. The talk also discusses formatting AI output, crafting requests, and analyzing embeddings for similarity.
The Rise of the AI Engineer
React Summit US 2023React Summit US 2023
30 min
The Rise of the AI Engineer
Watch video: The Rise of the AI Engineer
The rise of AI engineers is driven by the demand for AI and the emergence of ML research and engineering organizations. Start-ups are leveraging AI through APIs, resulting in a time-to-market advantage. The future of AI engineering holds promising results, with a focus on AI UX and the role of AI agents. Equity in AI and the central problems of AI engineering require collective efforts to address. The day-to-day life of an AI engineer involves working on products or infrastructure and dealing with specialties and tools specific to the field.
Web Apps of the Future With Web AI
JSNation 2024JSNation 2024
32 min
Web Apps of the Future With Web AI
Web AI in JavaScript allows for running machine learning models client-side in a web browser, offering advantages such as privacy, offline capabilities, low latency, and cost savings. Various AI models can be used for tasks like background blur, text toxicity detection, 3D data extraction, face mesh recognition, hand tracking, pose detection, and body segmentation. JavaScript libraries like MediaPipe LLM inference API and Visual Blocks facilitate the use of AI models. Web AI is in its early stages but has the potential to revolutionize web experiences and improve accessibility.
Building the AI for Athena Crisis
JS GameDev Summit 2023JS GameDev Summit 2023
37 min
Building the AI for Athena Crisis
Join Christoph from Nakazawa Tech in building the AI for Athena Crisis, a game where the AI performs actions just like a player. Learn about the importance of abstractions, primitives, and search algorithms in building an AI for a video game. Explore the architecture of Athena Crisis, which uses immutable persistent data structures and optimistic updates. Discover how to implement AI behaviors and create a class for the AI. Find out how to analyze units, assign weights, and prioritize actions based on the game state. Consider the next steps in building the AI and explore the possibility of building an AI for a real-time strategy game.
What AI Can, Can’t, and Shouldn’t Do for Games
C3 Dev Festival 2024C3 Dev Festival 2024
26 min
What AI Can, Can’t, and Shouldn’t Do for Games
AI in game development has evolved rapidly, with generative AI being a focus. However, game developers like Romero Games have concerns about ethics and prefer using AI to automate processes and make creative work easier. AI has been used in games for decades, from path-finding AI to decision trees. Procedural world building and advanced AI technology are pushing the boundaries of FPS games. Different teams within a company have different approaches to the use of AI, depending on their specific needs and requirements.

Workshops on related topic

AI on Demand: Serverless AI
DevOps.js Conf 2024DevOps.js Conf 2024
163 min
AI on Demand: Serverless AI
Top Content
Featured WorkshopFree
Nathan Disidore
Nathan Disidore
In this workshop, we discuss the merits of serverless architecture and how it can be applied to the AI space. We'll explore options around building serverless RAG applications for a more lambda-esque approach to AI. Next, we'll get hands on and build a sample CRUD app that allows you to store information and query it using an LLM with Workers AI, Vectorize, D1, and Cloudflare Workers.
Leveraging LLMs to Build Intuitive AI Experiences With JavaScript
JSNation 2024JSNation 2024
108 min
Leveraging LLMs to Build Intuitive AI Experiences With JavaScript
Featured Workshop
Roy Derks
Shivay Lamba
2 authors
Today every developer is using LLMs in different forms and shapes, from ChatGPT to code assistants like GitHub CoPilot. Following this, lots of products have introduced embedded AI capabilities, and in this workshop we will make LLMs understandable for web developers. And we'll get into coding your own AI-driven application. No prior experience in working with LLMs or machine learning is needed. Instead, we'll use web technologies such as JavaScript, React which you already know and love while also learning about some new libraries like OpenAI, Transformers.js
Llms Workshop: What They Are and How to Leverage Them
React Summit 2024React Summit 2024
66 min
Llms Workshop: What They Are and How to Leverage Them
Featured Workshop
Nathan Marrs
Haris Rozajac
2 authors
Join Nathan in this hands-on session where you will first learn at a high level what large language models (LLMs) are and how they work. Then dive into an interactive coding exercise where you will implement LLM functionality into a basic example application. During this exercise you will get a feel for key skills for working with LLMs in your own applications such as prompt engineering and exposure to OpenAI's API.
After this session you will have insights around what LLMs are and how they can practically be used to improve your own applications.
Table of contents: - Interactive demo implementing basic LLM powered features in a demo app- Discuss how to decide where to leverage LLMs in a product- Lessons learned around integrating with OpenAI / overview of OpenAI API- Best practices for prompt engineering- Common challenges specific to React (state management :D / good UX practices)
Working With OpenAI and Prompt Engineering for React Developers
React Advanced Conference 2023React Advanced Conference 2023
98 min
Working With OpenAI and Prompt Engineering for React Developers
Top Content
Workshop
Richard Moss
Richard Moss
In this workshop we'll take a tour of applied AI from the perspective of front end developers, zooming in on the emerging best practices when it comes to working with LLMs to build great products. This workshop is based on learnings from working with the OpenAI API from its debut last November to build out a working MVP which became PowerModeAI (A customer facing ideation and slide creation tool).
In the workshop they'll be a mix of presentation and hands on exercises to cover topics including:
- GPT fundamentals- Pitfalls of LLMs- Prompt engineering best practices and techniques- Using the playground effectively- Installing and configuring the OpenAI SDK- Approaches to working with the API and prompt management- Implementing the API to build an AI powered customer facing application- Fine tuning and embeddings- Emerging best practice on LLMOps
Building AI Applications for the Web
React Day Berlin 2023React Day Berlin 2023
98 min
Building AI Applications for the Web
Workshop
Roy Derks
Roy Derks
Today every developer is using LLMs in different forms and shapes. Lots of products have introduced embedded AI capabilities, and in this workshop you’ll learn how to build your own AI application. No experience in building LLMs or machine learning is needed. Instead, we’ll use web technologies such as JavaScript, React and GraphQL which you already know and love.
Building Your Generative AI Application
React Summit 2024React Summit 2024
82 min
Building Your Generative AI Application
WorkshopFree
Dieter Flick
Dieter Flick
Generative AI is exciting tech enthusiasts and businesses with its vast potential. In this session, we will introduce Retrieval Augmented Generation (RAG), a framework that provides context to Large Language Models (LLMs) without retraining them. We will guide you step-by-step in building your own RAG app, culminating in a fully functional chatbot.
Key Concepts: Generative AI, Retrieval Augmented Generation
Technologies: OpenAI, LangChain, AstraDB Vector Store, Streamlit, Langflow