2017-04-26 101 views
0

當我構建項目時(無論是否使用終端的maven)集成測試不運行。 這是日誌:構建期間不運行Spring引導集成測試

15:10:20.381 [main] DEBUG org.springframework.test.context.junit4.SpringJUnit4ClassRunner - SpringJUnit4ClassRunner constructor called with [class com.company.abc.restrictions.AddInterfaceTest] 
15:10:20.396 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating CacheAwareContextLoaderDelegate from class [org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate] 
15:10:20.412 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating BootstrapContext using constructor [public org.springframework.test.context.support.DefaultBootstrapContext(java.lang.Class,org.springframework.test.context.CacheAwareContextLoaderDelegate)] 
15:10:20.427 [main] DEBUG org.springframework.test.context.BootstrapUtils - Instantiating TestContextBootstrapper for test class [com.company.abc.restrictions.AddInterfaceTest] from class [org.springframework.boot.test.context.SpringBootTestContextBootstrapper] 
15:10:20.669 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.company.abc.transactions.VisaCreditTest]: using defaults. 
15:10:20.684 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] 
15:10:20.684 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [or[email protected]557caf28, org.springframework.test[email protected]408d971b, org.springframework.boot.test.a[email protected]6c6cb480, org.springfra[email protected]3c46e67a, org.springframew[email protected]c730b35, org.sp[email protected]206a70ef, org.spri[email protected]292b08d6, org.springf[email protected]22555ebf, org.springframework[email protected]36ebc363, org.springframework.boot.test.autoconfi[email protected]45752059, org.springframework.boo[email protected]34e9fd99, org.springframework.boot.test.autoconfi[email protected]3c41ed1d] 
15:10:20.684 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Neither @ContextConfiguration nor @ContextHierarchy found for test class [com.company.abc.transactions.VisaDebitTest], using SpringBootContextLoader 
15:10:20.684 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.company.abc.transactions.VisaDebitTest]: class path resource [com/company/abc/transactions/VisaDebitTest-context.xml] does not exist 
15:10:20.684 [main] DEBUG org.springframework.test.context.support.AbstractContextLoader - Did not detect default resource location for test class [com.company.abc.transactions.VisaDebitTest]: class path resource [com/company/abc/transactions/VisaDebitTestContext.groovy] does not exist 
15:10:20.684 [main] INFO org.springframework.test.context.support.AbstractContextLoader - Could not detect default resource locations for test class [com.company.abc.transactions.VisaDebitTest]: no resource found for suffixes {-context.xml, Context.groovy}. 
15:10:20.684 [main] DEBUG org.springframework.test.context.support.ActiveProfilesUtils - Could not find an 'annotation declaring class' for annotation type [org.springframework.test.context.ActiveProfiles] and class [com.company.abc.transactions.VisaDebitTest] 
15:10:20.684 [main] DEBUG org.springframework.boot.test.context.SpringBootTestContextBootstrapper - @TestExecutionListeners is not present for class [com.company.abc.transactions.VisaDebitTest]: using defaults. 
15:10:20.684 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener, org.springframework.boot.test.autoconfigure.restdocs.RestDocsTestExecutionListener, org.springframework.boot.test.autoconfigure.web.client.MockRestServiceServerResetTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.MockMvcPrintOnlyOnFailureTestExecutionListener, org.springframework.boot.test.autoconfigure.web.servlet.WebDriverTestExecutionListener, org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] 
15:10:20.700 [main] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper - Using TestExecutionListeners: [or[email protected]6ad82709, org.springframework.test[email protected]510f3d34, org.springframework.boot.test.a[email protected]7817fd62, org.springfra[email protected]8297b3a, org.springframew[email protected]2362f559, org.sp[email protected]b2c9a9c, org.spri[email protected]4c178a76, org.springf[email protected]fa4c865, org.springframework[email protected]3bd82cf5, org.springframework.boot.test.autoconfi[email protected]544fa968, org.springframework.boo[email protected]247bddad, org.springframework.boot.test.autoconfi[email protected]d35dea7] 
15:10:20.700 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved @ProfileValueSourceConfiguration [null] for test class [com.company.abc.restrictions.AddInterfaceTest] 
15:10:20.700 [main] DEBUG org.springframework.test.annotation.ProfileValueUtils - Retrieved ProfileValueSource type [class org.springframework.test.annotation.SystemProfileValueSource] for class [com.company.abc.restrictions.AddInterfaceTest] 

Results : 

Tests run: 0, Failures: 0, Errors: 0, Skipped: 0 

這是主要的測試類:

@RunWith(SpringRunner.class) 
@SpringBootTest(classes = MyServiceStarter.class, webEnvironment= SpringBootTest.WebEnvironment.DEFINED_PORT, 
     properties = {"flyway.locations=filesystem:../database/h2", "server.port=9100", "spring.profiles.default=dev"}) 
@Category(IntegrationTest.class) 
public abstract class AbstractModulIntegrationTest { ... } 

任何信息表示讚賞。

回答

0

如果您usign彈簧引導父POM,你可以進入它,看看這些線

   <plugin> 
        <groupId>org.apache.maven.plugins</groupId> 
        <artifactId>maven-surefire-plugin</artifactId> 
        <configuration> 
         <includes> 
          <include>**/*Tests.java</include> 
          <include>**/*Test.java</include> 
         </includes> 
         <excludes> 
          <exclude>**/Abstract*.java</exclude> 
         </excludes> 
        </configuration> 
       </plugin> 

正如你可以看到任何摘要排除。因此它沒有執行。更改測試類的名稱,或覆蓋這個插件,刪除此行

<exclude>**/Abstract*.java</exclude> 
+0

的事情是,我的同事的機器上正常工作。 (我們剛剛檢查過)。所以可能不是這個原因。但是,無論如何,謝謝。 – IKo

+0

您的AbstractModulIntegrationTest中是否有任何內容或只有註釋?請添加任何非抽象測試,例如VisaCreditTest。另外,我注意到使用@Category(IntegrationTest.class)。你有TestSuite嗎? –