Skip to content

feat(unit tests): Implement CTest (Cest) unit tests for all classes and functions #93

Description

@just1po1nt0

Feature Category

Build/Deployment

Problem Statement

Currently, there are a lot of bugs that go undetected until the app is rolled out to be tested on a real app (such as Launchpad's backend). This means there is a lot of back-and-forth with identifying the bugs and fixing the issue, then building and trying again, and again until everything works as intended. This is very problematic and time-consuming, and must be simplified.

Testing is a key tool for producing and maintaining robust, valid software.

Proposed Solution

CTest or Cest is a testing tool bundled with CMake for executing and evaluating automated tests for software projects. It is useful for solving this exact issue where instead of watching the whole app fail, it runs in isolated chunks where every function is mocked individually to find the exact point where it breaks.

I recommend implementing it to mitigate the problems outlined in the Problem Statement.

API Design

#include <cest>

describe("testing additions", []() {
    it("adds 1 + 2 to equal 3", []() {
        expect(sum(1, 2)).toBe(3);
    });
});

Alternative Solutions

Google Test (GTest) and Google Mock (GMock) combined is the most widely used testing framework. It would work too, and is likely more useful than CTest. I chose CTest for its resemblance of Jest from JavaScript, which I am already familiar with.

Use Case

In a large app that is consistently maintained, it is important to make sure that everything runs well after a change has been made. Introducing automated CTest or GTest into GitHub Actions will make sure that pull requests for which the tests fail are blocked automatically. It is also useful when compatibility with older versions of lightlib is important.

Impact and Scope

Dev-environment only. Does not affect deployed apps.

Contribution

  • I would like to implement this feature
  • I need guidance on implementation
  • I can help with testing

Metadata

Metadata

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions