我與春天有和EbeanMaven的測試中失敗安裝階段,但測試階段內確定
protected static ApplicationContext ctx;
@BeforeClass
public static void initSpringContext() {
ctx = new ClassPathXmlApplicationContext("spring-context.xml");
}
public class SomeTest extends SpringBase {
@Test
public void emptyTest() {}
}
一個空的Java測試我有類裝載了一個問題:
Caused by: javax.persistence.PersistenceException: models.Flat is NOT an Entity Bean registered with this server?
問題已解決與pom配置
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
</configuration>
</plugin>
此修復程序「mvn clean test」運行正常後,但「mvn clean install」失敗,出現嚴重問題eption 我想這是因爲集成測試階段。 我試圖在maven-failsafe-plugin中配置useSystemClassLoader,使用param -Dskip.integration.test = true運行,但沒有什麼區別,我感覺這個插件根本沒有調用。
此外,我還比較了由「mvn clean test」和「mvn clean verify」產生的surefire-reports - 測試套件中的部分「屬性」在兩種情況下都是相同的。
跳過集成測試也將是一個可接受的解決方案。
Maven 2.2.1 OS - Tested under Windows and Debian
如果它可以幫助,錯誤的堆棧跟蹤:
Caused by: javax.persistence.PersistenceException: models.Flat is NOT an Entity Bean registered with this server?
at com.avaje.ebeaninternal.server.core.DefaultServer.createQuery(DefaultServer.java:1008)
at com.avaje.ebeaninternal.server.core.DefaultServer.createQuery(DefaultServer.java:965)
at com.avaje.ebeaninternal.server.core.DefaultServer.find(DefaultServer.java:1001)
at com.avaje.ebean.Ebean.find(Ebean.java:1143)
at flats.crawler.managers.CrawlerManager.initCrawlerHashes(CrawlerManager.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299)
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132)
... 48 more
我已經運行兩個命令 「MVN全新安裝-X」 和 「MVN乾淨的測試-X」 比較試驗classpathes: 在第二種情況下第一殼體
[DEBUG] PATH\MODULE\target\MODULE-1.0.jar
[DEBUG] PATH\MODULE\target\classes
這就是爲什麼Ebean找不到類
um,故障安全和surefire不使用相同的測試類,所以集成測試類和單元測試類是不一樣的。這是一個單元測試課程還是集成測試課程?你也可以讓我們知道異常堆棧跟蹤等。 – eis
我知道IT測試和單元測試是不同的東西,我想使它成爲通常的單元測試。項目中根本沒有IT測試。 –
我的意思是,故障安全插件將綁定到* IT.java,其中surefire將綁定到* Test.java - >您不會同時擁有兩個,所以我不認爲這是問題,如果你只有* Test.java測試。 你可以用'mvn -X'上的調試標誌運行maven,看它是否發出任何新信息? – eis