0

How can I store a macro name in a variable and then later use it?

For example:

Set myVariable = "AssertEquals"

Do $$$myVariable(...)

OR

Set myVariable = "$$$AssertEquals"

Do myVariable(...)

Thought I could do something like the following but that doesn't work either (I get CLASS DOES NOT EXIST).

Do $CLASSMETHOD("%UnitTest.TestCase","AssertEqualsViaMacro",....)
DAiMor
  • 3,185
  • 16
  • 24
Conor
  • 85
  • 1
  • 10

1 Answers1

2

No way, macroses expended during compile time, but you going to use them in runtime. I think you should better explain what you actually going to achieve. And you'll get more answers if you ask here.

DAiMor
  • 3,185
  • 16
  • 24
  • Ok thanks. Was just trying to loop though a set of UnitTests where the type of test (e.g. AssertEquals) is defined in a table column. – Conor Sep 16 '19 at 14:18
  • so, why not just use this way? `Do $CLASSMETHOD("current testcase class","AssertEqualsViaMacro",....)` – DAiMor Sep 17 '19 at 07:48
  • When I do the following I get an error. Class UnitTests.MyTest Extends %UnitTest.TestCase { Method TestAdd() { ... ... ... Do $CLASSMETHOD("UnitTests.MyTest","AssertStatusOKViaMacro",tStatus, "Testing....") See error below. LogStateStatus:0:TestAdd:ERROR #5002: Cache error: zTestAdd+3^UnitTests.MyTest.1 *AssertStatusOKViaMacro,UnitTests.MyTest <<==== **FAILED** – Conor Sep 18 '19 at 15:48
  • Sorry, it should be `$method($this, "AssertEqualsViaMacro", "here some description", ...args)` – DAiMor Sep 21 '19 at 12:13