无法运行单元测试... java.lang.ExceptionInInitializerError

2020-09-03 11:36发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)你好, 我在执行自己的单元测试...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


你好,

我在执行自己的单元测试方法时遇到一些问题...我认为问题在于创建ProductModel,但是我不确定...

错误消息:

  java.lang.ExceptionInInitializerError
      在de.hybris.platform.servicelayer.model.DefaultNewModelContextFactory.getTenantId(DefaultNewModelContextFactory.java:48)
      在de.hybris.platform.servicelayer.model.DefaultNewModelContextFactory.createNewBuilder(DefaultNewModelContextFactory.java:39)
      在de.hybris.platform.servicelayer.model.DefaultNewModelContextFactory.createNew(DefaultNewModelContextFactory.java:30)
      在de.hybris.platform.servicelayer.model.AbstractItemModel。(AbstractItemModel.java:65)
      在de.hybris.platform.core.model.ItemModel。(ItemModel.java:76)
      在de.hybris.platform.core.model.product.ProductModel。(ProductModel.java:675)
      在com.unic.hybris.interdiscount.b2b.facades.impl.DefaultIDB2BProductFacadeTest.testGetProduct(DefaultIDB2BProductFacadeTest.java:72)
      在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
      在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      在org.junit.runners.model.FrameworkMethod $ 1.runReflectiveCall(FrameworkMethod.java:44)
      在org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      在org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
      在org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      在org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      在org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
      在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:69)
      在org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:48)
      在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:231)
      在org.junit.runners.ParentRunner上$ 1.schedule(ParentRunner.java:60)
      在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      在org.junit.runners.ParentRunner.access处$ 000(ParentRunner.java:50)
      在org.junit.runners.ParentRunner上$ 2.evaluate(ParentRunner.java:222)
      在org.junit.runners.ParentRunner.run(ParentRunner.java:292)
      在org.junit.runners.Suite.runChild(Suite.java:128)
      在org.junit.runners.Suite.runChild(Suite.java:24)
      在org.junit.runners.ParentRunner $ 3.run(ParentRunner.java:231)
      在org.junit.runners.ParentRunner上$ 1.schedule(ParentRunner.java:60)
      在org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
      在org.junit.runners.ParentRunner.access处$ 000(ParentRunner.java:50)
      在org.junit.runners.ParentRunner上$ 2.evaluate(ParentRunner.java:222)
      在org.junit.runners.ParentRunner.run(ParentRunner.java:292)
      在org.junit.runner.JUnitCore.run(JUnitCore.java:157)
      在com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
      在com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
      在com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
      在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
      在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      在com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
  引起原因:de.hybris.bootstrap.config.BootstrapConfigException:无法确定platformhome
      在de.hybris.bootstrap.config.ConfigUtil.getPlatformHome(ConfigUtil.java:136)
      在de.hybris.bootstrap.config.ConfigUtil.getPlatformConfig(ConfigUtil.java:354)
      在de.hybris.bootstrap.config.ConfigUtil.loadLog4JProperties(ConfigUtil.java:369)
      在de.hybris.platform.core.Log4JUtils.readConfig(Log4JUtils.java:105)
      在de.hybris.platform.core.Log4JUtils.startup(Log4JUtils.java:59)
      在de.hybris.platform.core.Registry。(Registry.java:67)
      ...更多42
  原因:de.hybris.bootstrap.config.BootstrapConfigException:无法确定core-items.xml的路径
      在de.hybris.bootstrap.config.ConfigUtil.getPlatformHome(ConfigUtil.java:85)
      ...更多47
 
 
  java.lang.ExceptionInInitializerError
      在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)处
      在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
      在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
      在java.lang.reflect.Constructor.newInstance(Constructor.java:526)
      在org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:31)
      在org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:24)
      在org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      在org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
      在org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
      在org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:98)
      在org.junit.runners.model.RunnerBuilder.runners(RunnerBuilder.java:84)
      在com.intellij.junit4.JUnit46ClassesRequestBuilder.collectWrappedRunners(JUnit46ClassesRequestBuilder.java:90)
      在com.intellij.junit4.JUnit46ClassesRequestBuilder.getClassesRequest(JUnit46ClassesRequestBuilder.java:51)
      在com.intellij.junit4.JUnit4TestRunnerUtil.buildRequest(JUnit4TestRunnerUtil.java:91)
      在com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:39)
      在com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:211)
      在com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:67)
      在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
      在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      在com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
  引起原因:de.hybris.bootstrap.config.BootstrapConfigException:无法确定platformhome
      在de.hybris.bootstrap.config.ConfigUtil.getPlatformHome(ConfigUtil.java:136)
      在de.hybris.bootstrap.config.ConfigUtil.getPlatformConfig(ConfigUtil.java:354)
      在de.hybris.bootstrap.config.ConfigUtil.loadLog4JProperties(ConfigUtil.java:369)
      在de.hybris.platform.core.Log4JUtils.readConfig(Log4JUtils.java:105)
      在de.hybris.platform.core.Log4JUtils.startup(Log4JUtils.java:59)
      在de.hybris.platform.testframework.HybrisJUnit4ClassRunner。(HybrisJUnit4ClassRunner.java:54)
      ...另外22个
  原因:de.hybris.bootstrap.config.BootstrapConfigException:无法确定core-items.xml的路径
      在de.hybris.bootstrap.config.ConfigUtil.getPlatformHome(ConfigUtil.java:85)
      ...另外27个


  

我的代码:

  @Test
  公共无效testGetProduct()引发异常{


      最终的ProductModel productModel = new ProductModel();
      productModel.setCode(" TEST_CODE");

      assert(true);
  }

  

我错过了一些配置吗?

非常感谢!

格里兹

6条回答
小熊yu生菜
2020-09-03 12:20

私有ProductModel getProductModel(){

最终ItemModelInternalContext上下文= ItemContextBuilder 
.createMockContextBuilder(CustomerModel.class,PK.NULL_PK,Locale.ENGLISH,Collections.emptyMap())
.build(); 最终的ProductModel productModel = new ProductModel(context); return productModel;}

一周热门 更多>