Results 1 to 3 of 3

Thread: AOP and Unit testing ?

  1. #1
    Join Date
    Aug 2004
    Location
    India
    Posts
    16

    Default 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. #2
    Join Date
    Aug 2004
    Location
    San Mateo, CA
    Posts
    1,265

    Default

    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
    Rod Johnson - GM, SpringSource Division, VMware
    http://www.springsource.com
    Spring From the Source

  3. #3
    Join Date
    Aug 2004
    Location
    India
    Posts
    16

    Default

    Quote 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
    Quote Originally Posted by Class A
    public class A {
    public String opn(String s)
    {
    return s.toUpperCase();
    }
    }
    The Test case class follows :
    Quote 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •