springrunner

Exclude ApplicationStartup Event listener when testing

北城余情 提交于 2019-12-24 06:46:19
问题 I recently added an ApplicationStartup class to my SpringBoot project @Component public class ApplicationStartup implements ApplicationListener<ApplicationReadyEvent> { ... It implements ApplicationListener. Now when I run my old JUNit tests that have nothing to do with that class, The testrunner tries to Run my StartupListener, which is neither necessary not appropriate in these cases. How do I skip the ApplicationListener when my tests initialize? @RunWith(SpringRunner.class)

NoClassDefFoundError: Tests fail during Maven test phase when SureFire forkCount is greater than 0

本秂侑毒 提交于 2019-12-13 00:23:05
问题 Issue Java 9 / Java 10 Module Mode: Tests failing due to initializationError: java.lang.NoClassDefFoundError: Could not initialize class org.springframework.test.context.junit4.SpringRunner when SureFire forkCount > 0 Spring Boot: 2.0.1.RELEASE Java: "10" 2018-03-20 (Vendor: Oracle Corporation) Maven: 3.5.3 maven-compiler-plugin: 3.7.0 maven-surefire-plugin: 2.21.0 macOS: 10.12.6 Relevant stack trace [INFO] --- maven-surefire-plugin:2.21.0:test (default-test) @ turbo --- [INFO] [INFO] -------

Is it OK to use SpringRunner in unit tests?

梦想与她 提交于 2019-12-06 12:10:26
问题 We are arguing about this approach with my colleagues. They say to use SpringRunner only on integration or functional levels. The question is what pros and cons of using it in level below? For example I have simple bean: public class RewardDurationCalculator { private Clock clock; public OptionalLong calculate(DurationType durationType, List<Pass> passes) { long now = Instant.now(clock).getEpochSecond(); switch (durationType) { case FULL_PASS: return getCurrentPassDuration(passes, now); case

Is it OK to use SpringRunner in unit tests?

故事扮演 提交于 2019-12-04 17:41:30
We are arguing about this approach with my colleagues. They say to use SpringRunner only on integration or functional levels. The question is what pros and cons of using it in level below? For example I have simple bean: public class RewardDurationCalculator { private Clock clock; public OptionalLong calculate(DurationType durationType, List<Pass> passes) { long now = Instant.now(clock).getEpochSecond(); switch (durationType) { case FULL_PASS: return getCurrentPassDuration(passes, now); case TILL_THE_END_OF_THE_CURRENT_ACTIVE_PASS: return getTimeInCurrentPassLeft(passes, now); } return