mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 13:26:10 +01:00
Allow name to be provided for overall test run
This commit is contained in:
parent
0bc42c5659
commit
b3db552cfa
@ -266,7 +266,10 @@ namespace Catch
|
||||
{
|
||||
if( !m_testingSpan.emitted )
|
||||
{
|
||||
m_config.stream() << "[Started testing]" << std::endl;
|
||||
if( m_config.getName().empty() )
|
||||
m_config.stream() << "[Started testing]" << std::endl;
|
||||
else
|
||||
m_config.stream() << "[Started testing: " << m_config.getName() << "]" << std::endl;
|
||||
m_testingSpan.emitted = true;
|
||||
}
|
||||
|
||||
|
@ -46,6 +46,8 @@ namespace Catch
|
||||
{
|
||||
m_xml = XmlWriter( m_config.stream() );
|
||||
m_xml.startElement( "Catch" );
|
||||
if( !m_config.getName().empty() )
|
||||
m_xml.writeAttribute( "name", m_config.getName() );
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
@ -30,6 +30,7 @@ namespace Catch
|
||||
// -o, --out filename to write to
|
||||
// -s, --success report successful cases too
|
||||
// -b, --break breaks into debugger on test failure
|
||||
// -n, --name specifies an optional name for the test run
|
||||
class ArgParser : NonCopyable
|
||||
{
|
||||
enum Mode
|
||||
@ -41,6 +42,7 @@ namespace Catch
|
||||
modeOutput,
|
||||
modeSuccess,
|
||||
modeBreak,
|
||||
modeName,
|
||||
modeHelp,
|
||||
|
||||
modeError
|
||||
@ -74,6 +76,8 @@ namespace Catch
|
||||
changeMode( cmd, modeSuccess );
|
||||
else if( cmd == "-b" || cmd == "--break" )
|
||||
changeMode( cmd, modeBreak );
|
||||
else if( cmd == "-n" || cmd == "--name" )
|
||||
changeMode( cmd, modeName );
|
||||
else if( cmd == "-h" || cmd == "-?" || cmd == "--help" )
|
||||
changeMode( cmd, modeHelp );
|
||||
}
|
||||
@ -179,6 +183,10 @@ namespace Catch
|
||||
if( m_args.size() != 0 )
|
||||
return setErrorMode( m_command + " does not accept arguments" );
|
||||
m_config.setShouldDebugBreak( true );
|
||||
case modeName:
|
||||
if( m_args.size() != 1 )
|
||||
return setErrorMode( m_command + " requires exactly one argument (a name)" );
|
||||
m_config.setName( m_args[0] );
|
||||
break;
|
||||
case modeHelp:
|
||||
if( m_args.size() != 0 )
|
||||
|
@ -171,6 +171,18 @@ namespace Catch
|
||||
m_shouldDebugBreak = shouldDebugBreakFlag;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
void setName( const std::string& name )
|
||||
{
|
||||
m_name = name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
std::string getName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
bool shouldDebugBreak() const
|
||||
{
|
||||
@ -228,7 +240,9 @@ namespace Catch
|
||||
bool m_showHelp;
|
||||
std::streambuf* m_streambuf;
|
||||
mutable std::ostream m_os;
|
||||
Include::What m_includeWhat;
|
||||
Include::What m_includeWhat;
|
||||
std::string m_name;
|
||||
|
||||
};
|
||||
|
||||
} // end namespace Catch
|
||||
|
@ -33,6 +33,9 @@ namespace Catch
|
||||
|
||||
virtual bool includeSuccessfulResults
|
||||
() const = 0;
|
||||
|
||||
virtual std::string getName
|
||||
() const = 0;
|
||||
};
|
||||
|
||||
class TestCaseInfo;
|
||||
|
Loading…
Reference in New Issue
Block a user