Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#7410 closed Patches (fixed)

Test Units (Cases and Suites) in Boost.Test do not capture __FILE__ and __LINE__ at declaration point making it impossible to provide source file linking using external test management tools

Reported by: Jamie Allsop <ja11sop@…> Owned by: Gennadiy Rozental
Milestone: Boost 1.59.0 Component: test
Version: Boost Development Trunk Severity: Problem
Keywords: Cc:

Description

We currently use Bitten as our continuous integration tool. We also use Boost.Test for all our unit tests. As Bitten integrates with Trac, which also provides the ability to browse our source repository, we want to be able to augment our test reports with links from test cases back to the source they appear in. In order to provide this capability we need to patch boost test so that FILE and LINE are captured in the test case and test suite macros. The patch attached to this ticket adds this capability.

Once this information is available it becomes easy to extract this information from the test output. We use human readable output but this works equally well with the XML output.

This can then be used by any number of continuous integration tools to provide much better test reports. In our case we turn each test case and test suite name into a link directly to the file and line in our source tree where the test unit was defined. This makes linking reports to actual source much more intuitive.

This is a relatively simple patch and I have another follow on patch that further enhances the reporting capability of Boost.Test with a view to easier integration to third party tools. I'll comment back with the ticket number when it is created. We currently use a similar patch to the attached with our development code with boost 1.48. The attached patch is against trunk.

Attachments (1)

boost_test_test_unit_file_and_line.diff (22.3 KB ) - added by Jamie Allsop <ja11sop@…> 10 years ago.
boost_test_test_unit_file_and_line.diff

Download all attachments as: .zip

Change History (6)

by Jamie Allsop <ja11sop@…>, 10 years ago

boost_test_test_unit_file_and_line.diff

comment:1 by Jamie Allsop <ja11sop@…>, 10 years ago

These patches, attached to:

#7397
Boost.Test, since boost 1.48 is using the deprecated Boost.Timer class
#7410
Test Units (Cases and Suites) in Boost.Test do not capture __FILE__ and __LINE__ at declaration point making it impossible to provide source file linking using external test management tools
#7417
Detailed test status is not available in the Boost.Test log (status, assertions, passed) and so live test case status cannot be tracked

...taken together allow for sophisticated test tools to be built on top of the Boost.Test output.

comment:2 by jaredgrubb@…, 10 years ago

The patch looks reasonable. My only comment is that it changes the test_case constructor, which could cause migration issues for anyone that may have subclassed or written other macros. Might be better to keep the original constructor around and just fill in some dummy values for file/line if that happens to get called.

comment:3 by Jamie Allsop <ja11sop@…>, 10 years ago

Actually that's a good point - some sort of dummy values would probably work well. The call to the creation of the Master Test Suite could then either use that constructor or actually be created using __FILE__ and __LINE__ since technically that is where the master test suite is created.

comment:4 by Gennadiy Rozental, 10 years ago

Resolution: fixed
Status: newclosed

Applied in trunk with some modifications. Thank you for the submission

comment:5 by Raffi Enficiaud, 7 years ago

Milestone: To Be DeterminedBoost 1.59.0
Note: See TracTickets for help on using tickets.