Description in OpenTap.TestPlan and OpenTap.TestStep?

Seems that testplan description is not exposed in OpenTap.Testplan?
Same for teststep description in OpenTap.TestStep. (16.2 Beta)
What am I missing?

Hi @GoranJohnsson,

You mean as a property? It is a kind of dynamically attached property.

You can get/set it using reflection, e.g:

// get
TypeData.GetTypeData(plan).GetMember("OpenTap.Description").GetValue(plan)
//set
TypeData.GetTypeData(plan).GetMember("OpenTap.Description").SetValue(plan, value)
2 Likes

Okey. How come these properties are so non-intuitive to access?

Got it to work now. So to get a TestStep Description you have to:
TypeData.GetTypeData(stepItem).GetMember(“OpenTap.Description”).GetValue(stepItem);

4 Likes

Related question: How can I get the Description of a teststep but from my resultlistener’s OnTestStepRunCompleted? TestStepRun doesn’t seem to have the attached properties?

Unfortunately, the description property is marked as “non-metadata,” which means that it’s specifically not included in the results parameters. This means that at the moment, what you’re trying to do isn’t possible.

However, for other properties that aren’t marked with the NonMetadataAttribute, you should be able to find them in the TestStepRun.Parameters property.

OK, too bad.
In my experience you typically want some additional information, besides step name, in each teststep. For example, a test instruction number or a “friendly” step name. The test shell and resultlistener(s) then use this info in GUI, logs, database etc.
As a workaround I currently use the Description field and this works for custom test steps that publish results. But for the standard steps like Sequence (that I use to group tests) this is not possible since I cannot access its Description from resultlistener.

Perhaps a coming enhancement to the base TestStep class to include some additional properties?

1 Like

Like a Comment or so? Maybe we could add a feature to dynamically add new properties from the UI? Those could also be used for scripting-like steps. That functionality could be added as a plugin.

Yes, one (or two) generic text properties available in all test steps (base class), editable in TA UI and accessible from ResultListener and test step code.
Not sure your suggestion handles all this?

Actually, if you know up front exactly what you need, the easiest is probably following the code in AttachedPropertyExample.cs. This is also the case if you want to add a property to all steps.

Otherwise, I am also thinking of adding a feature to dynamically add any kind of property on any step. This could also be useful for other things, e.g Dialog step, generic “Expression” step.