Parse XML function names and call within whole assembly

Posted by Matt Clarkson on Stack Overflow See other posts from Stack Overflow or by Matt Clarkson
Published on 2010-05-13T15:44:16Z Indexed on 2010/05/13 15:44 UTC
Read the original article Hit count: 339

Filed under:
|
|

Hello all,

I have written an application that unit tests our hardware via a internet browser.

I have command classes in the assembly that are a wrapper around individual web browser actions such as ticking a checkbox, selecting from a dropdown box as such:

BasicConfigurationCommands
EventConfigurationCommands
StabilizationCommands

and a set of test classes, that use the command classes to perform scripted tests:

ConfigurationTests
StabilizationTests

These are then invoked via the GUI to run prescripted tests by our QA team. However, as the firmware is changed quite quickly between the releases it would be great if a developer could write an XML file that could invoke either the tests or the commands:

<?xml version="1.0" encoding="UTF-8" ?> 
<testsuite>
    <StabilizationTests>
        <StressTest repetition="10" />
    </StabilizationTests>
    <BasicConfigurationCommands>
        <SelectConfig number="2" />
        <ChangeConfigProperties name="Weeeeee" timeOut="15000" delay="1000"/>
        <ApplyConfig />
    </BasicConfigurationCommands> 
</testsuite>

I have been looking at the System.Reflection class and have seen examples using GetMethod and then Invoke. This requires me to create the class object at compile time and I would like to do all of this at runtime.

I would need to scan the whole assembly for the class name and then scan for the method within the class.

This seems a large solution, so any information pointing me (and future readers of this post) towards an answer would be great!

Thanks for reading,

Matt

© Stack Overflow or respective owner

Related posts about c#

Related posts about Xml