Skip to content

Namespace tests with filename to reduce test naming conflicts #2175

@zfields

Description

@zfields

Description

I have a hardware abstraction layer interface, as well as a driver interface. I have multiple drivers utilizing the HAL interface, while implementing the driver interface. This plugin approach causes me to have identically named tests across multiple test files.

For example:

TEST_CASE("init() returns `E_HAL_INIT`, when HardwareAbstractionLayer::init() returns an error", "[init][hal][error]") {

When I attempt to compile multiple test files into a single test runner, then I get the following name collisions...

error: TEST_CASE( "init() returns `SUCCESS`, when no errors occur" ) already defined.
        First seen at signal_generator.test.cpp:36
        Redefined at led_ntsc_driver.test.cpp:179

I noticed you have a flag on the test binary, --filenames-as-tags. I am curious if you could incorporate the "test case + tags" into a test identifier to achieve uniqueness.

This seems like an elegant solution to this problem, unless you already have a workaround. If so, would you please share the preferred pattern with me.

Thanks,
Zak

Metadata

Metadata

Assignees

No one assigned

    Labels

    Good First IssueIssues that can be undertaken by someone new to the project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions