Wednesday, June 29, 2011 9:14 AM
I'd like to implement an IPostProcessor which invokes the actions which are described in the TransitionSystem.
I iterate over the transition system, identifying flows I wish to invoke. I find the Action member of a Transition has information about the action, but it is difficult to actually invoke it. I first need to convert all the Arguments (SerializableExpressions) into objects of the un-serialized type (so I can later use them with reflection), but this is proving complex due to different NodeTypes - some, such as ExpressionType.Constant, are easily convertible into objects, which others (MemberInit) are less so.
Is there a conveniene method I can use to invoke a given Action ? Alternatively, could you post some example / code which achieves this task, or converts the Arguments into objects I can use when invokeing the method through reflection?
While I'm at it, another small question - is there a way to print information from the IPostProcessor into VS's output pane (I found no way to do this).
Thursday, June 30, 2011 4:44 AMModerator
My understanding is that you want to implement a postprocessor to invoke actions, can you tell me more about your requirements? I think the typical scenario of using post-processor is to iterate the transition system and output some statistics to analyze the model easily. If you want to invoke the actions, why not use test code generation and let the test code to invoke the actions?
Maybe you want to traverse the transition system using your own strategy, then Dynamic Traversal is a good way to try (more details can be found at http://msdn.microsoft.com/en-us/library/ff793088.aspx). In Dynamic Traversal, you also use the transistion system as the input, and we will provide delegates which can be used to invoke the actions directly.
Friday, July 01, 2011 1:52 PM
Thanks for your response.
I wish to create an XML representation of the test cases (which I feed into an execution system to run the tests). Using unit tests in order to generate the XMLs is what I currently do (with action implementations generating XML content), however it's cumbersome and I thought using IPostProcessor would be cleaner and easier in the long run (I also use IPostProcessor to generate documentation). According to SpecExplorer documentation, IPostProcessor is the place to implement this sort of thing. I believe I could accomplish the task by using IPostProcessor with action-specific logic per action, but it's cleaner to use the Action implementation to generate the XML (separating the model from feature-specific information).
It looks like IDyanmicTraversal should accomodate my needs, though if I had the delegates (or a method that generates a delegate from an Action) I believe IPostProcessor would do the job as well. I'll put some effort into it and ask further if I run into difficulties.
Thanks again for the prompt and precise response !
Sunday, July 03, 2011 1:33 PM
From what I understand, the workflow of working with DynamicTraversal still involves generating test code, then running it. In my case where my implementation creates test packages, the flow supported by the Generate Test Code option (whether dynamic traversal or not) will be:
Generate test suite -> Add generated files to VS -> Recompile, refresh UT list -> Create VS UT ordered list containing new tests -> Run the test suite -> Feed XMLs into other automation engine
Meanwhile, I also generate documentation, simply by right-clicking a machine and Perform User Tasks (I implement IPostProcessor).
Since I use the same flow for 35 machines (and expect them to grow to hundreds), having the ability to select all -> Perform User Tasks, and have this create both the documentation and the XML packages would be valuable. Having an intermediate auto-generated code creates overhead which is not necessary, if I can simply run the flow from IPostProcessor. This would involve invocation by reflection and not generating test code for the delegates. I would appreciate it if you have some sample that converts the Action class arguments into Objects that can be passed to Reflection invocation (this might be what you use for OTF, which I have not yet tried).
I would also appreciate if you could answer my 2nd question - about outputting into SpecExplorer output window from a class implementing IPostProcessor so I can give feedback on the results of IPostProcessor.
Thanks again, your help is appreciated