Maven 1.x AspectJ Plugin

autoweave test code before running tests

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 3.1
  • Component/s: None
  • Labels:
    None
  • Environment:
    maven-1.0-rc1, WinXP, J2SE 1.4.2
  • Number of attachments :
    1

Description

I have recently started to use virtual mock objects (http://www.virtualmock.org) that make heavy use of AspectJ in the test cases of a maven project.

I noticed that the latest AspectJ plugin has support for autoweaving the project sources, but not the test sources.

Once you have resolved how to weave the compiled classes instead of just the JAR, how difficult would it be to autoweave the test classes as well?

Activity

Hide
Vincent Massol added a comment -

It would be easy to autoweave the test but I'm not sure it should be part of the aspectj plugin. I have on my machine another plugin that I have never committed (and which is not finished) which I called ajtest. For AspectJ test. It's for implement unit testing with AspectJ. It looks for test sources in src/test-aspectj which allows to cleanly spearate pure JUnit tests from AspectJ-based unit tests. Not sure if I'll have the time to work on it before a long time but this is something that I would have liked to see too. That said, I'm currently working on Cactus2 (along with a Maven plugin) which uses the same principle (it's using AspectWerkz) except the code runs on server side and most of my free time is currently used by Cactus2.

Show
Vincent Massol added a comment - It would be easy to autoweave the test but I'm not sure it should be part of the aspectj plugin. I have on my machine another plugin that I have never committed (and which is not finished) which I called ajtest. For AspectJ test. It's for implement unit testing with AspectJ. It looks for test sources in src/test-aspectj which allows to cleanly spearate pure JUnit tests from AspectJ-based unit tests. Not sure if I'll have the time to work on it before a long time but this is something that I would have liked to see too. That said, I'm currently working on Cactus2 (along with a Maven plugin) which uses the same principle (it's using AspectWerkz) except the code runs on server side and most of my free time is currently used by Cactus2.
Hide
. added a comment -

Weave test classes

  • added goal aspectj:test-compile
  • created aspectj taglib to avoid duplication
  • documented, of course
Show
. added a comment - Weave test classes
  • added goal aspectj:test-compile
  • created aspectj taglib to avoid duplication
  • documented, of course
Hide
. added a comment -

The patch is against latest CVS

Show
. added a comment - The patch is against latest CVS
Hide
. added a comment -

In the patch, the goal aspectj:test-compile should have

prereqs="aspectj:compile"

and this should be added:

<!-- By calling a goal from the test plugin we ensure that all its
properties are loaded and are thus accessible from this plugin -->
<test:dependency-handle/>
<j:set var="testPlugin" value="${pom.getPluginContext('maven-test-plugin')}"/>

Show
. added a comment - In the patch, the goal aspectj:test-compile should have prereqs="aspectj:compile" and this should be added: <!-- By calling a goal from the test plugin we ensure that all its properties are loaded and are thus accessible from this plugin --> <test:dependency-handle/> <j:set var="testPlugin" value="${pom.getPluginContext('maven-test-plugin')}"/>
Hide
Joshua White added a comment -

As of version 3.2, it seems that this fix has reversed itself. No matter where I put my aspect as a pregoal, it always seems to use the value of "maven.compile.src.set" for the value of "maven.test.compile.src.set". I am assuming that this is because it doesn't have access to the test plugin as referenced above.

Show
Joshua White added a comment - As of version 3.2, it seems that this fix has reversed itself. No matter where I put my aspect as a pregoal, it always seems to use the value of "maven.compile.src.set" for the value of "maven.test.compile.src.set". I am assuming that this is because it doesn't have access to the test plugin as referenced above.
Hide
Joshua White added a comment -

After doing a maven clean, the problem went away. I am not sure what could have happened, but I will let you know if any of my users have this problem as I roll out the maven build to the developers.

Thanks,

Joshua

Show
Joshua White added a comment - After doing a maven clean, the problem went away. I am not sure what could have happened, but I will let you know if any of my users have this problem as I roll out the maven build to the developers. Thanks, Joshua
Hide
Lukas Theussl added a comment -

This issue was closed a long time ago, please open a new one if you still have problems (ideally with a reproducible test case attached).

Show
Lukas Theussl added a comment - This issue was closed a long time ago, please open a new one if you still have problems (ideally with a reproducible test case attached).

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: