Skip to content

Add TEST_PROPERTY macro for JUnit per-test-case properties#1884

Open
thetic wants to merge 6 commits into
cpputest:masterfrom
thetic:feature/test-property
Open

Add TEST_PROPERTY macro for JUnit per-test-case properties#1884
thetic wants to merge 6 commits into
cpputest:masterfrom
thetic:feature/test-property

Conversation

@thetic
Copy link
Copy Markdown
Contributor

@thetic thetic commented Apr 1, 2026

Summary

  • Adds TEST_PROPERTY(name, value) (C++) and TEST_PROPERTY_C(name, value) (C) macros that attach key-value string properties to the current test case
  • Properties appear as <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 set
  • Property names and values are XML-encoded

The feature routes through the existing UtestShell → TestResult → TestOutput call chain: JUnitTestOutput overrides printTestProperty to store properties on per-test-case result nodes and emit them when writing XML. All other TestOutput subclasses get a default no-op, but the feature is available to extend existing or future output implementations.

thetic added 4 commits March 31, 2026 21:18
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.
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 1, 2026

Coverage Status

coverage: 99.285% (+0.004%) from 99.281%
when pulling 976c4b8 on thetic:feature/test-property
into 79c066e on cpputest:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants