Skip to content

[ISSUE-812] Use an LLM to aid in generating basic unit tests for all classes#909

Draft
kblricks wants to merge 2 commits intoSharedDevelopmentfrom
issue-812-llm-unit-tests
Draft

[ISSUE-812] Use an LLM to aid in generating basic unit tests for all classes#909
kblricks wants to merge 2 commits intoSharedDevelopmentfrom
issue-812-llm-unit-tests

Conversation

@kblricks
Copy link

@kblricks kblricks commented Feb 5, 2026

Closes #812

Description

Adds a markdown file for instructing Copilot to generate test cases, and a markdown file for instructing Copilot to use relevant context when reviewing PRs

Checklist (Mandatory for new features)

  • Added Documentation
  • Added Unit Tests

Testing (Mandatory for all changes)

  • GPU Test: test-medium-connected.xml Passed
  • GPU Test: test-large-long.xml Passed

@kblricks kblricks self-assigned this Feb 5, 2026
@kblricks kblricks linked an issue Feb 5, 2026 that may be closed by this pull request
@kblricks kblricks marked this pull request as ready for review February 5, 2026 00:26
Copilot AI review requested due to automatic review settings February 5, 2026 00:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds two instructional markdown files to help GitHub Copilot assist with unit test generation and code reviews in the Graphitti project.

Changes:

  • Adds .github/prompts/generate-unit-tests.prompt.md with comprehensive guidance for generating Google Test unit tests for C++ code
  • Adds .github/copilot-instructions.md with project-specific coding standards, conventions, and PR review guidelines

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.

File Description
.github/prompts/generate-unit-tests.prompt.md Provides detailed instructions for LLM-assisted unit test generation, including Google Test basics, test structure requirements, assertion references, and guidelines for analyzing existing tests
.github/copilot-instructions.md Documents Graphitti project overview, C++17 coding standards, formatting conventions, and comprehensive PR review checklist to guide Copilot in code reviews

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +207 to +230
class {ClassName}Test : public ::testing::Test {
protected:
void SetUp() override {
// Initialize test objects before each test
}

void TearDown() override {
// Clean up resources after each test
}

// Shared test data members
};

// Standalone test example
TEST({ClassName}Test, MethodName_ValidInput_ReturnsExpected) {
// Arrange - set up test data

// Act - call the function under test

// Assert - verify the results
}

// Fixture-based test example
TEST_F({ClassName}Test, MethodName_EdgeCase_HandlesCorrectly) {
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The template shows inconsistent naming for test fixtures and test suites. In the actual codebase, test fixtures use a "Fixture" suffix (e.g., InputManagerFixture), while standalone TEST() macros use the class name without a suffix (e.g., TEST(ConnectionsFactory, ...)). The template should be updated to reflect this convention:

  • For fixtures: class {ClassName}Fixture : public ::testing::Test
  • For standalone tests: TEST({ClassName}, ...)
  • For fixture-based tests: TEST_F({ClassName}Fixture, ...)

Copilot uses AI. Check for mistakes.
x++;
}

int f(a)
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code example shows an invalid C++ function signature int f(a) where parameter a is missing a type. This should be corrected to something like int f(int a) to be valid C++. While this error appears to have been copied from docs/Developer/codingConventions.md:35, it should be fixed in this new file.

Suggested change
int f(a)
int f(int a)

Copilot uses AI. Check for mistakes.
Comment on lines +109 to +141
```cpp
class A {
const int i = 100;
const int * const num = &i;

int function1(char c) const;
const int* function2(const char* string) const;
};
```

### Copy and Move Operations

- A class must make it clear whether it is copyable, move-only, or neither by explicitly declaring and/or deleting the appropriate operations
- Use compiler options `= default` and `= delete`

```cpp
class Copyable {
public:
Copyable(const Copyable& other) = default;
Copyable& operator=(const Copyable& other) = default;
};

class MoveOnly {
public:
MoveOnly(MoveOnly&& other) = default;
MoveOnly& operator=(MoveOnly&& other) = default;
};

class NotCopyable {
public:
NotCopyable(const NotCopyable&) = delete;
NotCopyable& operator=(const NotCopyable&) = delete;
};
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code examples use inconsistent indentation (appears to be 1-2 spaces) which doesn't match the project's 3-space indentation standard. While this was copied from docs/Developer/cppStyleGuide.md, it should be corrected in this new file to use 3 spaces for consistency with the actual codebase (e.g., see Simulator/Core/Simulator.h:28-32).

Copilot uses AI. Check for mistakes.
Comment on lines +63 to +73
```cpp
if (x > m) {
x--;
} else {
x++;
}

int f(a)
{
return a;
}
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code example appears to use 4-space indentation instead of the project's 3-space standard. This should be corrected to match the project convention documented on line 43.

Copilot uses AI. Check for mistakes.

- **Language**: C++17
- **Build System**: CMake
- **Testing**: Custom testing framework with unit and regression tests
Copy link

Copilot AI Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description states "Custom testing framework with unit and regression tests" but this is incorrect. The project uses Google Test (gtest) for unit testing, as evidenced by the GoogleTestsTutorial.md documentation and all test files in Testing/UnitTesting/. This should be updated to "Google Test (gtest) for unit testing and custom regression tests" or similar.

Suggested change
- **Testing**: Custom testing framework with unit and regression tests
- **Testing**: Google Test (gtest) for unit testing and custom regression tests

Copilot uses AI. Check for mistakes.
@kblricks kblricks marked this pull request as draft February 5, 2026 00:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use an LLM to aid in generating basic unit tests for all classes

1 participant