Forum Discussion

tristaanogre's avatar
tristaanogre
Esteemed Contributor
9 years ago
Solved

Data Reflection implementation in TestComplete

This is probably a bit of an advanced question.

For some time now, I've been tweaking and working on a Table-driven Framework that I wrote with TestComplete using JScript and CSV files for the data sources. It works pretty well as it is. However, one of the challenges that this framework has is that, for each keyword in the table of test steps, I need to add another case to a switch statement in a particular code unit. For small projects with a minimal variety of test steps, this isn't a problem. But when you get to large enterprise systems with complex applications, many different forms and entry points into the test cases, etc., those switch statements are going to get MASSIVE and an absolute bear to maintain.

Something that I've been playing around with is implementing something like reflection as it is implemented in Java SE8. While the JavaScript support in TC 12 makes it such that I can create more complex classes in TC, one thing it doesn't have is the ability to have compiled "classes" that I can utilize for something like the "Class.forName()" implementation in Java. Now, again, I can probably do this by creating multiple units, each effectively creating on of the JavaScript/JScript prototype classes that I'm already using, but the maintenance of this would be that, each time I need to add a new class, I need to add another "USEUNIT" line to my main script unit. This is not undoable but I guess I'm looking for ideas of how else to implement this.

Another option I've thought of is that, each time I need to create a new class for a test type, create it as a TestComplete Script extension. I think that this will work as long as I can get the script execution methods to call properly. 

 

I guess I'm looking for help brainstorming how to simulate Data Reflection in the most efficient way possible. I'm more of a script developer and TC expert and rather junior when it comes to actual software development so I'm hoping that there are some experts out here who can give me a brain boost in my investigation.

Thanks!