Version 13

    Proposal for changes in testing framework architecture

     

     

     

    Goal:

    The goal is to have test defined in a way that is easier to write and easier to folow.

     

     

     

    Single Test Case

    Test contain of several Portlets and Servlets each of has:

     

    • Pointcuts defined like: 'Portlet_A_doView', 'Portlet_B_processAction', 'Portlet_C_init' and etc.

    • TestId which identifies a group of portlets for single test case

     

     

    Generic Stuff

    To make things easier to implement most of logic should be in a class like GenericTestPortlet

     

     

     

    So PortletA class extending GenericTestPortlet should only override methods such as:

    • getTestId() - to identify to which test case it belongs

    • getComponentId() - to provide compoent name which will be part of 'Pointcut'

     

     

    Having those we can define sample doView() implementation in GenericTestPortlet

     

     

    //in render() method we check testId to render only if it is current test id
    //Then we dispatch to doView() where we have code like this
    Action a = TestContext.getSequenceRegistry().getAction(getComponentId()+"_doView",TestContext.getRequestCount());
    if (action != null && action instanceOf RenderAction)
    {
       Result r = action.run(this, RenderRequest, RenderResponse);
       //and we render result or whatever
    }
    else
    {
       //we render FailureResult
    } 
    

     

     

    When we define a actions for a tests we simply feed SequenceRegistry with several actions seting Pointcuts and RequestCounts for them:

     

    sequence.add("PortletC_doView", requestCount, new Action.TEST(){
       public Result run(Portlet p, Request rq, Response rp){
       ...
       } 
    });
    
    

    What it buys us

    • We keep portet and servlet objects simple. So we can simply define several portlets and servlets for one test case

    • When we need to folow test logic we just need to read code with actions being injected into sequence. No need to track flow between several Portlets

     

    Concerns

    1. Where should we inject Actions into sequence

      1. We can do this in one of test portlets (main one) in it's constructor - as each Portlet should have only one instance. So when Portlet is deployed it registers and inject it's actions into sequence

      2. We can use ServletContextListener which will be invoked during web-app containing our test set deployment. So in that moment we can build whole sequence. But holding sequences of all test portlets in one class ca decreese readability. Additionally we should avoid defining test names in to much places. So we shouldn't define what test have to be called twice - on client and on server.

     

     

    Refactorings

    1. We can provide described changes not afecting 'test' module

    2. What we do is simply

      1. Change update code of GenericTestPortlet

      2. Rip logic from current test cases and put code for every request count into sequence