Add TEST_PROPERTY macro for JUnit per-test-case properties#1884
Open
thetic wants to merge 6 commits into
Open
Conversation
Adds TEST_PROPERTY(name, value) for C++ and TEST_PROPERTY_C(name, value) for C, allowing test bodies to attach key-value metadata that appears in JUnit XML output as <property> elements inside <testcase> blocks. Properties flow through the existing UtestShell -> TestResult -> TestOutput call chain, with JUnitTestOutput storing them on per-test-case result nodes and emitting them when writing XML. The <properties> block is only emitted when at least one property is present. Property names and values are XML-encoded.
Adds a PropertySpyOutput that captures printTestProperty calls, and two tests that drive the macros through ExecFunctionTestShell with a spy result to verify the full routing chain from macro invocation to output. Also adds the cpputest_test_property_c_caller helper in the C test file to exercise TEST_PROPERTY_C from actual C code.
Fixes -Wmissing-prototypes error with clang-cl -Werror.
We don't need a macro that just forwards to a function.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TEST_PROPERTY(name, value)(C++) andTEST_PROPERTY_C(name, value)(C) macros that attach key-value string properties to the current test case<properties><property name="..." value="..."/></properties>inside the<testcase>element in JUnit XML output (standard JUnit XML format); the block is omitted entirely when no properties are setThe feature routes through the existing
UtestShell → TestResult → TestOutputcall chain:JUnitTestOutputoverridesprintTestPropertyto store properties on per-test-case result nodes and emit them when writing XML. All otherTestOutputsubclasses get a default no-op, but the feature is available to extend existing or future output implementations.