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

Aperta
#2,859 4 commenti 8 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
cpp
Ambito
testing-qa

Direzione di ricerca

Inizia esaminando il percorso deprecato Catch::getResultCapture().getCurrentTestName() e l’implementazione proposta di RunContext che utilizza tracker di sezione attivi. Traccia il modo in cui vengono rappresentati i nomi correnti dei test e delle sezioni, quindi definisci un accesso stabile al nome del test e al nome della sezione, con supporto per la gerarchia se fattibile. Il lavoro è completato quando i nomi richiesti sono disponibili senza dipendere da API deprecate e sono coperti da test appropriati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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 https://github.com/catchorg/Catch2/issues/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 https://github.com/catchorg/Catch2/issues/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();

Lingua principale
C++
Stelle
21.6k
Fork
3.4k
Merge medio
3g 12h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di catchorg/Catch2

Tutte le issue di catchorg/Catch2

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.