/quick-test

/quick-test generates unit tests.

Use it to quickly create a basic set of tests covering key behaviors of your code.

Using /quick-test

  1. Open a file: Open a file in your project.

  2. Activate Qodo Gen: Click the Qodo Gen logo in the Extensions bar.

  3. Focus: Select the part of the code you want to generate a quick test for. It could be a few lines of code, a method, an entire file, your local changes and more. Check out our Focus documentation to learn more.

  4. Call the Command: Type /quick-test in the chatbox and hit the send key or click the arrow button.

  5. (Optional) Add optional instructions: You can give Qodo Gen any specific guidelines.

  6. Result! Qodo Gen will generate a test tailored for your code.

  7. (Optional) Continue your chat: To give Qodo Gen more instructions, just type a command or ask a question to keep chatting.

Example

Given this code snippet:

function sayHello(name) {
    return "Hello World! I'm " + name;
}

const user = "Username";
const hello = sayHello(user);

console.log(hello);

Command

/quick-test [optional instructions]

Response

Qodo Gen will analyze your code, identifying key behaviors to create focused and effective test cases. Click on any behavior to understand its testing significance.

Happy Path:The function should return a greeting message that includes the provided name.

This is the primary functionality of the function and should be tested to ensure it concatenates the name correctly.

Edge Case: The function should handle an empty string as the name and return a greeting message with no name.

Testing with an empty string ensures that the function can handle cases where no name is provided, which is a potential edge case.

Error Case: The function should handle non-string inputs gracefully, either by converting them to strings or by throwing an error.

The function expects a string input, so it's important to test how it behaves with non-string inputs to ensure robustness.

import { expect } from 'chai';

describe('sayHello', () => {
    it('test_sayHello_with_valid_name', () => {
        const result = sayHello('Alice');
        expect(result).to.equal("Hello World! I'm Alice");
    });

    it('test_sayHello_with_empty_name', () => {
        const result = sayHello('');
        expect(result).to.equal("Hello World! I'm ");
    });

    it('test_sayHello_with_non_string_input', () => {
        const result = sayHello(123 as any);
        expect(result).to.equal("Hello World! I'm 123");
    });
});

Last updated

Logo

2025 Qodo. All Rights Reserved.