在spring-boot中运行Junit测试的错误消息

时间:2019-01-30 11:25:25

标签: java spring-boot junit

我有一个Java Maven项目,带有多弹簧启动模块。当我在项目的类上运行spring boot Junit测试时,它运行正常,除了“历史”模块外,所有测试都在开始时以红色输出(在intellji IDE中)通过所有“测试”模块。

在通过的简单类测试中,这是红色警告输出。

    function detectAdblock(){
      if( window.canRunAds === undefined){
        console.log("Adblock detected")
        var donateBanners = document.getElementsByClassName("donations");
        for (i = 0; i < donateBanners.length; i++) {
            donateBanners[i].style.display = "block";
            console.log("Banner displayed! " + i)
        }
      }
      else {
        console.log("Adblock not detected");
      }
    }
    window.onload = detectAdblock;

班级:

 an 30, 2019 1:15:52 PM org.springframework.test.context.support.AbstractContextLoader generateDefaultLocations
INFO: Could not detect default resource locations for test class [io.px.historynode.services.EmployeeServiceTest]: no resource found for suffixes {-context.xml, Context.groovy}.
Jan 30, 2019 1:15:52 PM org.springframework.boot.test.context.SpringBootTestContextBootstrapper getDefaultTestExecutionListenerClassNames
INFO: Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [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, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener]
Jan 30, 2019 1:15:52 PM org.springframework.boot.test.context.SpringBootTestContextBootstrapper getTestExecutionListeners
INFO: Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@3967e60c, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@60d8c9b7, org.springframework.boot.test.mock.mockito.MockitoTestExecutionListener@48aaecc3, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@7c0c77c7, org.springframework.test.context.support.DirtiesContextTestExecutionListener@7adda9cc, org.springframework.boot.test.mock.mockito.ResetMocksTestExecutionListener@5cee5251]

测试:

@Data
@Service
public class EmployeeService {
   public void init() {

   }
}

Pom.xml:

@ContextConfiguration(classes = {
       EmployeeService.class
})
@TestPropertySource(locations = "classpath:test.properties")
@SpringBootTest
@RunWith(SpringRunner.class)
public class EmployeeServiceTest {

   @Autowired
   private EmployeeService employeeService;

   @Test
   public void init() {
       employeeService.init();
   }
}

0 个答案:

没有答案