deargui-vpl/docs/llm/testing.md
2026-02-03 18:25:25 +01:00

3.0 KiB

Testing Guide

This project uses a combination of C++-based unit/functional tests and TypeScript-based end-to-end (E2E) tests to ensure code quality and correctness.

1. Unit & Functional Tests (C++/Google Test)

The C++ tests are built on the Google Test framework and are designed to test individual classes and functions in isolation.

How to Run

To run the entire C++ test suite, use the corresponding npm script from the project root:

npm run test:core

This command will:

  1. Compile the test executable (core_tests).
  2. Run the tests using CTest.

How to Add a New Test

  1. Create a new _test.cpp file inside the applications/tests/ directory.
  2. Include "commons-test.h" and any other necessary headers.
  3. Write your tests using the Google Test TEST_F macro, inheriting from the AppTest fixture if you need an application instance.
  4. Add the name of your new file to the add_executable command in applications/tests/CMakeLists.txt.

2. End-to-End Tests (TypeScript/Vitest)

The E2E tests are built with Vitest and are designed to test the compiled command-line application (nodehub_d.exe) as a whole.

  • Location: All E2E tests are located in the tests/ directory at the project root.
  • Test Runner: A helper function for executing the binary is located in tests/commons.ts. This helper manages the command-line arguments and process execution.
  • Example: See tests/e2e.test.ts for an example of how to use the runCli helper to test the application's behavior.

How to Run

To run the entire E2E test suite, use the corresponding npm script from the project root:

npm run test:e2e:core

This command will invoke Vitest, which will discover and run all *.test.ts files inside the tests/ directory.

How to Add a New Test

  1. Create a new _test.ts file inside the tests/ directory.
  2. Import describe, it, and expect from "vitest", and the runCli helper from "./commons".
  3. Write your tests. Each test should call runCli with the desired command-line arguments and then use expect to assert the correctness of the stdout, stderr, or exit code.