Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide means to obtain current test case name and current section name #2859

Open
sparkles43 opened this issue Apr 17, 2024 · 1 comment
Open

Comments

@sparkles43
Copy link

Description

I propose the following changes:

  • Add a feature to get the current test case's name
  • Add a feature to get the current section's name
  • Optionally: Add a feature to get the current section's hierarchy of names

These changes are useful if additional data for testing is loaded from or written to a filesystem. Directories and filenames could depend on the current section and thereby reduce duplication.

Additional context

In the past sometimes requests for these features were made but none ever reached a stable upstream (or non-deprecated) state. Especially the issue #510 (by @mlogan) contained a request for such features. However, it was resolved since workarounds were available.

Feature to get the current section's hierarchy of names

In the issue #510 @jgm-radez suggested (and @isidore supported) the following approach to obtain the current section's hierarchy of names:

virtual std::vector<std::string> getCurrentSectionNames() const {
            std::vector<std::string> retval;
            for(std::vector<ITracker*>::const_iterator iter=m_activeSections.begin(); iter!=m_activeSections.end(); ++iter)
                    retval.push_back((*iter)->nameAndLocation().name);
            return retval;
}

(Assumption: implemented in RunContext)

Feature to get the current test case's name

This feature is currently available in Catch2 but it was marked as deprecated in commit 57c346a by @philsquared and I could not find a reason for it. Why was this done?

Catch::getResultCapture().getCurrentTestName();

@acidtonic
Copy link

I came here to create this exact issue. I am chaining very deep SECTIONS for testing cascading reads/writes for a compression driver and I sometimes get a rare failure out of a few hundred million assertions and it's tough to nail down the exact SECTION chain to produce the bug.

Would love a simple Breadcrumb trail sort of mechanism to iterate section names or just get them as a long string.

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

No branches or pull requests

2 participants