miércoles, 21 de octubre de 2009

AgilePoint extensions unit tests

Hi again,
After a few months resting I am here again with a new interesting blog entry :-).
I am going to spend a few entries to talk about unit testing your AgilePoint extensions (AgileParts and AgileWorks basically).
When I started developing AgileParts one of the things I realise, is how much time I wasted testing my code.
I had to create a process to test the AgilePart in Envision, deploy the process, attach to corresponding w3wp process, and then, I can debug.
Too much time wasted getting the AgilePart in context for debugging, there must be a better way to do this.

In the next entries I am going to show the process I followed to create a Unit Testing Framework for AgilePoint that have saved me much time.

This is a summary of what I considere that is needed to get this framework:

  • Base test clasess for AgilePart and AgileWork tests.
  • IWFApi implementation to be used as a mock class.
  • IWFAdmin implementation (used in very specific implementations).
  • An easy mechanism to set context process variables and AgileParts/Works parametrization to allow testing multiple scenarios.
  • An extension of WFProcessInstance to be used as mock class in tests.
  • Several code snippets to increase the speed of coding even more :-)
Once I have this, I can create a new Unit Test in Visual Studio for my AgileParts in a few seconds.

The basic idea is to provide a mechanism to run AgileParts and AgileWorks without running processes in AgilePoint Engine, creating mock classes that simulate the behavior of the engine.

This is the code I need to test an AgileWork using my framework:

[TestMethod]
public void TestAgileWork()

{

WFAdmMock myMock = new WFAdmMock();

api.RunAgileWork(CreateDescriptor(CreateDescriptorWork), typeof(DynamicParallelActivity), GetWFManualActivity, GetWFProcessInstance, GetManualWorkItems, WFEvent.ASSIGN_WORKITEM, myMock);

}

protected Ascentn.Workflow.Base.WFAgileWorkDescriptor CreateDescriptorWork()

{

DynamicParallelActivityDescriptor desc = new DynamicParallelActivityDescriptor();

desc.Participant = "xxx";

desc.Name = "name";

desc.ID = "Test";

desc.DisplayName = "TestDisplay";

NameValue[] nvs = new NameValue[2];

nvs[0] = new NameValue("Task1", "user1");

nvs[1] = new NameValue("Task2", "user2");

desc.WorkItems = nvs;

return desc;

}


As you can see, I do not work much to create a test.

If you are interested in this ... comments are welcome.

No hay comentarios:

Publicar un comentario