# Test step attributes available in ResultListener?

**URL:** <https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514>\
**Category:** Technical\
**Created:** [November 5, 2021, 1:44pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514 "2021-11-05T13:44:47Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![GoranJohnsson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/goranjohnsson/32/140_2.png) [@GoranJohnsson](https://forum.opentap.io/u/GoranJohnsson)\
**Post date:** [November 5, 2021, 1:44pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/1 "2021-11-05T13:44:47Z")

</div>

As I understand test step attributes (e.g. Unit) are not available to result listeners (in TestStepRun). Is this correct or have I missed something?

---

<div class="post-metadata">

**Author:** ![ivan.diep](https://avatars.discourse-cdn.com/v4/letter/i/b5e925/32.png) [@ivan.diep](https://forum.opentap.io/u/ivan.diep)\
**Post date:** [November 5, 2021, 4:21pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/2 "2021-11-05T16:21:33Z")

</div>

I believe attributes are available anywhere in OpenTAP. Specifically for your example though, I have been able to use the unit attribute in a ResultsListener. In the example shown below, I’ve just attached a random unit attribute to one of the variables in the example results listener in %TAP\_PATH%\Packages\SDK\Examples:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/bd784277f863ef863a7bbf130b2ccb910fa6e5de.png)  
 ![image](https://us1.discourse-cdn.com/flex020/uploads/opentap/original/1X/927f6b20636551bc7dcce7aa8651ca6197e8eca2.png)

---

<div class="post-metadata">

**Author:** ![GoranJohnsson](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/goranjohnsson/32/140_2.png) [@GoranJohnsson](https://forum.opentap.io/u/GoranJohnsson)\
**Post date:** [November 5, 2021, 4:41pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/3 "2021-11-05T16:41:58Z")

</div>

Thanks, but I was referring to the OnTeStepRunCompleted method in the result listener implementation. Its TestStepRun argument doesnt seem to contain the attributes from the calling test step? Perhaps the idea is to publish attributes (e.g. unit) in the results table?

---

<div class="post-metadata">

**Author:** ![ivan.diep](https://avatars.discourse-cdn.com/v4/letter/i/b5e925/32.png) [@ivan.diep](https://forum.opentap.io/u/ivan.diep)\
**Post date:** [November 5, 2021, 11:07pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/4 "2021-11-05T23:07:12Z")

</div>

I understand now. There are ways to retrieve the information inside an attribute: [Retrieving Information Stored in Attributes | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/standard/attributes/retrieving-information-stored-in-attributes#:~:text=First%2C%20declare%20an%20instance%20of%20the%20attribute%20you,simply%20use%20its%20properties%20to%20get%20the%20values.), and from there you could pass those values into Results.PublishTable(), but I don’t think there is a built in variable that stores this data.

@brennen_direnzo Do you have any experience with this?

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [November 11, 2021, 6:57pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/5 "2021-11-11T18:57:44Z")

</div>

I extended ResultSource.Publish, so it accepts more than just a name and value. Like @GoranJohnsson, I had a couple other pieces of metadata I wanted, like the units. So the extension combines the name and metadata into a formatted string, and calls Publish with that. Then my custom Result Listeners call a method to parse out the name and metadata.

---

<div class="post-metadata">

**Author:** ![andries](https://avatars.discourse-cdn.com/v4/letter/a/e56c9b/32.png) [@andries](https://forum.opentap.io/u/andries)\
**Post date:** [August 17, 2022, 11:39am UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/6 "2022-08-17T11:39:28Z")

</div>

> [@david-wsd](#):
>
> I extended ResultSource.Publish, so it accepts more than just a name and value. Like @GoranJohnsson, I had a couple other pieces of metadata I wanted, like the units. So the extension combines the name and metadata into a formatted string, and calls Publish with that. Then my custom Result Listeners call a method to parse out the name and metadata.

any chance you have published that work somewhere? I am currently in the same need of some more advanced ways of publishing test results.

---

<div class="post-metadata">

**Author:** ![david-wsd](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opentap.io/david-wsd/32/204_2.png) [@david-wsd](https://forum.opentap.io/u/david-wsd)\
**Post date:** [August 17, 2022, 4:22pm UTC](https://forum.opentap.io/t/test-step-attributes-available-in-resultlistener/514/7 "2022-08-17T16:22:43Z")

</div>

Hi @andries, it’s not published publicly, sorry. I haven’t yet delved into open-sourcing our code outside of the company.

@connospp brought up a similar issue, and I commented here:

> [@Change result listener parameters on the fly](https://forum.opentap.io/t/change-result-listener-parameters-on-the-fly/788/5):
>
> @connospp I’ve bumped into these same challenges. The ResultTable class is limited, as it’s essentially a collection of name (string) and value (IConvertible) pairs. There doesn’t seem to be a built-in way to attach other metadata (e.g. a file path) to a result parameter. This was actually the very first thing I worked on when I began OpenTAP development several years ago. I spent a couple months extending the results architecture. In my case, I ended up formatting several pieces of metadata …
