I am building a unit test system for my apps, and was trying to find a way of determining what methods a class has in order to generate test cases automatically
I have found the GetReflectMethods of the Progress.Lang.Class object, but can't find any information on the "Progress.Reflect.Method" class that is returned.
Do you have any idea on this ?
from the class browser:
METHOD PUBLIC Progress.Reflect.Method EXTENT GetReflectMethods ()
Member of Progress.Lang.Class
This code compiles:
DEF VAR a AS CLASS Progress.Reflect.Method EXTENT NO-UNDO.
a = e:GetClass():GetReflectMethods().
Where e is an ABL class.
However, when I run it, I get a "not implemented" error (5876)
Anyone got any more clues ? Peter ? Shelley ?
Julian,
Unfortunately, I don't think there is a way to programmatically determine what methods a class has. I do know that GetReflectMethods() definitely won't do the job for you. It's part of an API that hasn't been fully implemented yet (as you found out), and wasn't intended to be exposed in 10.2B (the same is true for the Progress.Reflect.Method class). It's a mistake that the class browser showed it and that the compiler didn't generate an error on the line where you tried to use it.
-- Wayne
Poo. That puts a spike in that plan
Looks like I'm going to have to xref (thanks mike!) the source code then.
Thanks for the information, though
On 2 Feb 2011 23:32, "Wayne Henshaw"
I was interested in hearing the response to your original post as I'd like to accomplish the same feat. Can you clarify what you are trying to do by using the XREF to find the methods to test?
Each method is documented in the xref file
for example
UserCodeTest.cls 35 METHOD PUBLIC,,,,,testDefaultUsers,void,
I'm building a generator that compiles each test unit and creates a
.txt file that contains a list of all methods in that class
starting with the word "test"
So if the UnitTestHarness program is asked to run a test on
"UserCode", it find the UserCodeTest.txt file, and reads in all the
methods, invoking each one dynamically
I will be releasing this unit test framework as open source once I've
bottomed out the basics.
Julian
jmls wrote:
Each method is documented in the xref file
for example
snip UserCodeTest.cls 35 METHOD PUBLIC,,,,,testDefaultUsers,void,
I'm building a generator that compiles each test unit and creates a
class.txt file that contains a list of all methods in that class
starting with the word "test"
So if the UnitTestHarness program is asked to run a test on
"UserCode", it find the UserCodeTest.txt file, and reads in all the
methods, invoking each one dynamically
I will be releasing this unit test framework as open source once I've
bottomed out the basics.
Julian
Many of the other TDD/unit testing frameworks use annotations to mark their methods for testing. This removes the requirement to name your methods "test" or "test_" or "TEST_ME_" or some similar convention. I know we don't have annotations-in-rcode in the ABL at the moment, but you can use the XREF method too. The annotations allow you to add all sorts of meta-data to the method .
So for instance, this code
@todo(task="refactor", action="investigate this mechanism. use property or just make Copy...() abstract?").
@test(bounds="none", allow-nulls="false").
define protected property StaticDatasetHandle as handle no-undo get. private set.
produces this output ...
C:\Devarea\projects\OEBP\referencecomponents\businesscomponents\src\OpenEdge\BusinessComponent\Entity\StandardBusinessEntity.cls C:\Devarea\projects\OEBP\referencecomponents\businesscomponents\src\OpenEdge\BusinessComponent\Entity\StandardBusinessEntity.cls 37 ANNOTATION todo(task=refactor, action=investigate this mechanism. use property or just make Copy...() abstract?)
C:\Devarea\projects\OEBP\referencecomponents\businesscomponents\src\OpenEdge\BusinessComponent\Entity\StandardBusinessEntity.cls C:\Devarea\projects\OEBP\referencecomponents\businesscomponents\src\OpenEdge\BusinessComponent\Entity\StandardBusinessEntity.cls 38 ANNOTATION test(bounds=none, allow-nulls=false)
(Incidentally, there's a unit-testing framework called OEUnit on OE Hive, which uses annotations for this information (http://www.oehive.org/project/oeunit). There looks to be some overlap with what you're trying to achieve)
-- peter
Thanks Peter, on both counts. When did the "@" sign appear for
annotations ? Never seen it before, but must have been around for
some time
Julian
jmls wrote:
Thanks Peter, on both counts. When did the "@" sign appear for
annotations ? Never seen it before, but must have been around for
some time
Julian
I believe it was introduced in 10.2A with the GUI for .NET . I don't remember the requirements that it satisfied, although I *think* that it had to do with the design canvas, on the .NET side. I know they're also used for the ESB native invocation integration.
OEA's Metacatalog (and here's where Mike beats me up for mentioning an unmentionalble ) can also read 'em and store them, so you could in theory at least use them for "real" TODO's. It would require an Eclipse view and linking back to the source code and it'd be awesome (IMHO); I suspect it's doable in the ABL (ie externally) but I've not quite been able to get there ... :
-- peter
OEA's Metacatalog (and here's where Mike beats me up for mentioning an unmentionalble )
You can get what you want, my friend