Announcement Announcement Module
Collapse
No announcement yet.
AOP and Unit testing ? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AOP and Unit testing ?

    Hi All,
    I have a idea evolving in my mind , it is using the AOP with the Unit Testing .It can be done with the JUnit , I am in a process of evaulation/analysing this idea and would be glad to hear opinion from the community.

    Regards
    Vicky

  • #2
    Vicky

    I've successfully used AOP in unit tests by injecting certain checks into methods via AOP. (Invariant checks etc). Is this what you had in mind?

    Rgds
    Rod

    Comment


    • #3
      Originally posted by Rod Johnson
      Vicky
      I've successfully used AOP in unit tests by injecting certain checks into methods via AOP. (Invariant checks etc). Is this what you had in mind?
      Rod ,
      I am not able to understand your statement clearly , ok let me just put a raw design down .Considering a class A as
      Originally posted by Class A
      public class A {
      public String opn(String s)
      {
      return s.toUpperCase();
      }
      }
      The Test case class follows :
      Originally posted by Class ATest
      import junit.framework.*;
      public class ATest extends TestCase{
      // Define All the Objects to be Tested
      private A a = new A();
      // Populate all the Objects needed to be Tested
      protected void setUp(){
      // Populate the Objects need for Test.The Population can be done using the properties
      // File
      }
      public void testOpn(){
      //
      String inputData = "Vicky"; // 1) Advisor(InputDataAdvisor) should prepare the InputData Object
      String expectedValue = "VICKY"; // 2) Advisor(ExpectedResultAdvisor) will prepare the ExpectedValue Object
      String executionValue = a.opn(inputData);
      assertEquals(expectedValue, executionValue); // 3)Advisor will check the object Contents.Its Data
      }
      public static void main(String args[]) {
      junit.textui.TestRunner.run(ATest.class);
      }
      }
      Now I dont want to write the ATest , rathar than I will focus on the Interceptor which basically will try to
      1) Prepare the I/p data.
      2) Prepare the o/p Data
      3) Verify the execution result
      Here I will prepare the standard Advisors and can be reused across the projects , just need to maintain the xml files .
      The concept seems to make the UnitTesting simple but needs a serious thought process .What do you think?

      Regards
      Vicky

      Comment

      Working...
      X