Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ajdt-dev] Accessing Method Parameters or return value of a method

You can use around advice or after returning advice to capture parameters and return value.

If this is the method you are interested in:

public String foo(int i, int j, int k) {
}

You can advise it like this:

String around(int i, int j, int k): execution(String foo(..)) && args(i,j,k) {
   // the arguments to the method are i,j,k but the method foo hasn’t run yet.
   String result = proceed(i,j,k); // this runs foo
   // result is the result of running that target method
}

or like this:

after(int i,int j,int k) returning(String s): execution(String foo(..)) && args(i,j,k) {
  // Here foo() has run and we have all the parameters and the return value
}

You can adapt that to your junit scenario. As you want to advise the method in the TestCase class you either have to use load time weaving to apply your aspect as your test runs, or use offline weaving to binary weave the junit jar to produce a new version with your instrumentation in it.

cheers,
Andy

On Nov 9, 2015, at 4:14 AM, ilke Muhtaroglu <ilke.muhtaroglu@xxxxxxxxx> wrote:

 


I want to get the result of a JUnit test. It is kept in TestResult class which is a return value of run method of TestCase class and also parameter of run method at TestCase class.

Please see this link for TestResult Class and TestCase class of JUnit.

http://junit.sourceforge.net/doc/cookstour/cookstour.htm

I can access the TestCase class when the test is run. 

My question is : Is it possible to acccess the parameters of a method when its run is finished or can I get the return value of a method after it is executed ?

Thanks for your help.

Sincerely

ilke

_______________________________________________
ajdt-dev mailing list
ajdt-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/ajdt-dev


Back to the top