Почему мой тест весны настроен с ошибкой при следующих недопустимых сообщениях об ошибках ниже? Все предложения приветствуются.Почему сообщение об ошибке Cryptic MultipleFailureException с помощью метода SpringJUnit4ClassRunner.withAfterClasses
JUnit Выходные
java.lang.NoClassDefFoundError: org/junit/runners/model/MultipleFailureException
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.withAfterClasses(SpringJUnit4ClassRunner.java:188)
at org.junit.runners.ParentRunner.classBlock(ParentRunner.java:145)
at org.junit.runners.ParentRunner.run(ParentRunner.java:235)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run (SpringJUnit4ClassRunner.java:163)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: java.lang.ClassNotFoundException: org.junit.runners.model.MultipleFailureException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
Console Output
INFO: org.springframework.test.context.support.DefaultTestContextBootstrapper - Загруженный имена классов TestExecutionListener по умолчанию от местоположения [META-INF /spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springf ramework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener] INFO: org.springframework.test.context.support.DefaultTestContextBootstrapper - возможно не создает экземпляр TestExecutionListener [org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]. Укажите пользовательские классы прослушивателя или сделайте классы-слушатели по умолчанию (и их необходимые зависимости) доступными. Класс нарушения: [org/springframework/transaction/interceptor/TransactionAttribute] INFO: org.springframework.test.context.support.DefaultTestContextBootstrapper - не удалось создать экземпляр TestExecutionListener [org.springframework.test.context.transaction.TransactionalTestExecutionListener]. Укажите пользовательские классы прослушивателя или сделайте классы-слушатели по умолчанию (и их необходимые зависимости) доступными. Класс нарушения: [org/springframework/transaction/interceptor/TransactionAttributeSource] INFO: org.springframework.test.context.support.DefaultTestContextBootstrapper - Использование TestExecutionListeners: [or[email protected]76959acc, org.springframework .test.context.support.DependencyInjectionTestExecutionListener @ 57e603e6, org.springfra[email protected]3e0a1e1f]
Вот фрагмент кода в целевой
@Service
public class PipApps {
@Resource(name = "apps")
private Properties apps;
@Autowired
private SitePreferenceHandler sitePreferenceHandler;
@Autowired
private PipsTable pipsTable;
private SitePreference sitePreference;
private Device device;
public PipApps(HttpServletRequest request, HttpServletResponse response){
sitePreference = sitePreferenceHandler.handleSitePreference(request, response);
device = DeviceUtils.getRequiredCurrentDevice(request);
}
public Properties getApps(){
return apps;
}
public Device getDevice(){
return device;
}
public SitePreference getSitePreference(){
return sitePreference;
}
public DeviceRouteTable getPipsTable(){
return pipsTable;
}
}
И тест фрагмент
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations={"src/test/resources/PipAppsTest-context.xml"})
public class PipAppsTest {
@Mock
SitePreferenceHandler sitePreferenceHandler;
@Autowired
PipApps pipApps;
...
}
Что не так полезно? Судя по трассе стека, вы используете несовместимую версию JUnit 4 с Spring Test. –
Я использовал JUnit 4.7. Теперь я пошел по вашей рекомендации и обновил ее до последней версии JUnit 4.12. Ошибка прекратилась. Это сообщение об ошибке является загадочным, хотя и, следовательно, не очень полезно. Но я полагаю, что за неопределенностью есть веская причина. – 000