在單元測試AspectJ的失敗,我們有一系列的單元測試,他們路過我的罰款之前,嘗試添加了依賴注入和方法記錄時間的一些方面被稱爲在我們休息的終點。autoweaving中的IntelliJ
在之前的測試中失敗的單元測試,我們得到兩個奇怪的錯誤:
[[email protected]] error aspect 'com.lutherconsulting.aphirm.log.DurationLoggingAspect' woven into 'com.lutherconsulting.aphirm.rest.ClientRest' must be defined to the weaver (placed on the aspectpath, or defined in an aop.xml file if using LTW).
和
[[email protected]] error aspect 'com.lutherconsulting.aphirm.log.DurationLoggingAspect' woven into 'com.lutherconsulting.aphirm.log.DurationLoggingAspect' must be defined to the weaver (placed on the aspectpath, or defined in an aop.xml file if using LTW).
我們使用AspectJ的Maven插件就讓它方面autoweave成Web應用程序。下面是我們針對Maven的pom.xml的配置。
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.8</version>
<configuration>
<showWeaveInfo>true</showWeaveInfo>
<complianceLevel>1.8</complianceLevel>
<source>1.8</source>
<target>1.8</target>
<Xlint>ignore</Xlint>
<encoding>UTF-8</encoding>
<verbose>true</verbose>
</configuration>
<executions>
<execution>
<goals>
<goal>test-compile</goal>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
奇怪的是,如果我建立war文件並將其部署到一個Tomcat實例這一切工作完全正常,或者如果我跑了我們所有的黃瓜功能測試。當我做這兩者中的任何一個時,方面編織得很好,並且我獲得了有關我註釋的其餘方法持續時間的數據,這些數據正確記錄到數據庫中。如果我從intelliJ運行特定的測試包或嘗試在intellij中運行所有的junit測試,它會因爲這兩個錯誤而失敗
這是我在Intellij中作爲運行/調試配置執行的方式單元測試?我沒想到我們的我們的應用程序的結構比任何正常的Web應用程序
- src
| - main
| - java
| - packages
| - resources
| - test
| - java
| - packages
| - resources
- pom.xml
我很欣賞的
對我來說這只是工作,我只是試過。也許你想重新導入你的Maven項目,或者只是在IDEA中打開Maven自動導入。儘管我使用編譯時編織。你使用LTW嗎? – kriegaex