Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8728077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:33:20+00:00 2026-06-13T08:33:20+00:00

In Boost.Test , how can I obtain the name of the current auto test

  • 0

In Boost.Test, how can I obtain the name of the current auto test case?

Example:

#include <boost/test/unit_test.hpp>
BOOST_AUTO_TEST_CASE(MyTest)
{
  std::cerr << "Starting " << test_name << std::endl;
  // lots of code here
  std::cerr << "Ending " << test_name << std::endl;
}

In the example, I want the variable test_name to contain “MyTest”.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:33:21+00:00Added an answer on June 13, 2026 at 8:33 am

    There is an undocumented* function that may be called for that purpose. The following line will flush the name of the current test to cerr:

    #include <boost/test/framework.hpp>
    
    ...
    
    std::cerr << boost::unit_test::framework::current_test_case().p_name 
              << std::endl;
    

    Note however that using this API does not flush the parameters in case of parametrized tests.

    You might also be interested in the test checkpoints** (which seems to be what you want to do.)

    #include <boost/test/included/unit_test.hpp>
    
    ...
    
    BOOST_AUTO_TEST_CASE(MyTest)
    {
      BOOST_TEST_CHECKPOINT("Starting");
      // lots of code here
      BOOST_TEST_CHECKPOINT("Ending");
    }
    

    EDIT

    * The current_test_case() function is now documented, see the official Boost documentation.

    ** BOOST_TEST_CHECKPOINT was previously called BOOST_CHECKPOINT. See the Boost changelog (1.35.0).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#define BOOST_TEST_MODULE MemoryLeakTest #include <boost/test/unit_test.hpp> #include <iostream> using namespace std; BOOST_AUTO_TEST_CASE( MemoryLeakTest) { double*
I have the following code: #include <iostream> #define BOOST_TEST_MODULE my test #include <boost/test/unit_test.hpp> BOOST_AUTO_TEST_CASE(
// BOOST Includes #include <boost/assign.hpp> // Boost::Assign #include <boost/assign/list_of.hpp> // Boost::Assign::List_Of #include <boost/assign/std/map.hpp> //
The following noddy test code: #include <iostream> #include <list> #include <boost/any.hpp> #include <boost/foreach.hpp> #include
How can I convert the following code to use boost unit test framework: #include
I can't understand why the code behaves this way? #include <iostream> #include <boost/fusion/container/vector.hpp> #include
When I have the following auto test case : class MyException: virtual public boost::exception,
Consider the following program: #include <iostream> #include boost/filesystem.hpp int main() { boost::filesystem::directory_entry d(test.txt); boost::filesystem::directory_entry
This is an output of Boost.Test when test case failes: bjam toolset=msvc ...patience... ...found
If I have user defined exceptions in my code, I can't get Boost test

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.