WDK ATF - "Negative" testing

mingus
edited December 17, 2008 in Documentum #1

Hello all,

We are wondering if there's a way to test the contents of an error popup window (e.g. text or icon) ?

Is it possible to have a test with an error (e.g. user cannot remove folder) to be successful instead of a failure?

Any ideas would be much appreciated,

Thanks a lot!

Saul

Best Answer

  • ljwong
    edited December 17, 2008 #2 Answer ✓

    Hi Saul,

    For WDK actions, the ATF automatically inserts validation code blocks into the test case class for the step which initiates the action.  If you're expecting the action to fail, you can remove this validation code.

    An example test step might look like:

    =====================================================================

       public class Step0_ExecuteNewcabinetAction extends ComponentTestStep implements IActionListener, IActionCompleteListener
       {
          public boolean isApplicable(Component component)
          {
             return ComponentHelper.getComponent(component, "actiondispatcher") != null;
          }

          public ClientEvent[] getClientEvents(Component component)
          {
             return NoOpClientEvent.getEvents();
          }

          public void onPreAction(String strActionId, ArgumentList args, Context context, Form form)
          {
             if (m_actionValidator == null)
             {
                m_actionValidator = ActionValidatorInstantiator.instantiateValidator(strActionId);
             }

             if (m_actionValidator != null)
             {
                m_actionValidator.saveInitialState(strActionId, args, context, form);
             }
          }

          public void onPostAction(String strActionId, ArgumentList args, Context context, Form form)
          {
          }

          public void onComplete(String strAction, boolean bSuccess, Map completionArgs)
          {
             if (m_actionValidator != null)
             {
                m_actionValidator.validateAction(strAction, bSuccess, completionArgs);
             }

             // todo: if applicable, add your onComplete (due to 'newcabinet' action) verification logic here

          }

          private ITestStepActionValidator m_actionValidator = null;
       }

    =====================================================================

    The code in red which calls the validateAction method can be removed which should allow for the test with an error scenario.

    Linda

Answers

  • ljwong
    edited December 17, 2008 #3 Answer ✓

    Hi Saul,

    For WDK actions, the ATF automatically inserts validation code blocks into the test case class for the step which initiates the action.  If you're expecting the action to fail, you can remove this validation code.

    An example test step might look like:

    =====================================================================

       public class Step0_ExecuteNewcabinetAction extends ComponentTestStep implements IActionListener, IActionCompleteListener
       {
          public boolean isApplicable(Component component)
          {
             return ComponentHelper.getComponent(component, "actiondispatcher") != null;
          }

          public ClientEvent[] getClientEvents(Component component)
          {
             return NoOpClientEvent.getEvents();
          }

          public void onPreAction(String strActionId, ArgumentList args, Context context, Form form)
          {
             if (m_actionValidator == null)
             {
                m_actionValidator = ActionValidatorInstantiator.instantiateValidator(strActionId);
             }

             if (m_actionValidator != null)
             {
                m_actionValidator.saveInitialState(strActionId, args, context, form);
             }
          }

          public void onPostAction(String strActionId, ArgumentList args, Context context, Form form)
          {
          }

          public void onComplete(String strAction, boolean bSuccess, Map completionArgs)
          {
             if (m_actionValidator != null)
             {
                m_actionValidator.validateAction(strAction, bSuccess, completionArgs);
             }

             // todo: if applicable, add your onComplete (due to 'newcabinet' action) verification logic here

          }

          private ITestStepActionValidator m_actionValidator = null;
       }

    =====================================================================

    The code in red which calls the validateAction method can be removed which should allow for the test with an error scenario.

    Linda