Can we run a test case of Hybris integration directly from eclipse?

I can run test cases from the hybris platform directory using the ant alltests' command, but not from eclipse.

Getting the following errors while running test cases from eclipse -> right click -> run as -> JUnit test

INFO [main] (junit) [HybrisContextFactory] - Refreshing SpringContext (hybris Application context - junit) took: (29.48 s) INFO [main] (junit) [HybrisContextFactory] Initializing application Spring ApplicationContext for tenant junit took: (31.27 s) INFO [main] (junit) [DefaultRMIRegistryService] Unexporting the registry. de.hybris.platform.core.UninstantiableCoreApplicationContextException: Error creating Spring application context. at de.hybris.platform.core.AbstractTenant.doStartupSafe(AbstractTenant.java:728) at de.hybris.platform.core.AbstractTenant.doStartUp(AbstractTenant.java:658) at de.hybris.platform.core.Registry.assureTenantStarted(Registry.java:639) at de.hybris.platform.core.Registry.activateTenant(Registry.java:700) at de.hybris.platform.core.Registry.setCurrentTenant(Registry.java:544) at de.hybris.platform.util.Utilities.setJUnitTenant(Utilities.java:1472) at de.hybris.platform.testframework.runlistener.PlatformRunListener.testRunStarted(PlatformRunListener.java:44) at de.hybris.platform.testframework.ChainingRunNotifierWrapper$1.notifyListener(ChainingRunNotifierWrapper.java:97) at de.hybris.platform.testframework.ChainingRunNotifierWrapper$SafeNotifier.run(ChainingRunNotifierWrapper.java:239) at de.hybris.platform.testframework.ChainingRunNotifierWrapper.fireTestRunStarted(ChainingRunNotifierWrapper.java:99) at de.hybris.platform.testframework.HybrisJUnit4ClassRunner.run(HybrisJUnit4ClassRunner.java:124) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) 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:678) 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: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 
+5
source share
2 answers

you will need to use ant from eclipse, (window> preferences> ant> runtime> ant home> and indicate where your ant Eg folder is: C:\Program Files\Ant\apache-ant-1.9.1 )

then (window> show view> Other> select ant)

then in your ant view click on adding build files (on the ant icon with +), this will show you all the projects in your working set (the platform extension must be imported) select platform/build.xml .

in the ant view, you will see that all the commands are displayed, you can perform any operation from eclipse instead of the command line.

0
source

Yes it is possible.

In fact, with Hybrid 6.1 and Eclispe Neon, I was able to run Junit tests from hybrid projects without any problems with the GUI.

To make tests work with Eclispe, you must make sure that

  • All your projects are correctly configured in Eclipse (no errors)
  • All dependencies are present in your workspace.
  • All configured extensions of your localextensions.xml file are registered in the path to the Eclipse JUnit test configuration class.

Follow these steps to fix the last point.

  • Open the Run menu
  • Open the Run Configurations dialog box
  • In the Run Configurations dialog box, select a test configuration
  • Click the Classpath tab.
  • Click the Add Projects button.
  • In the Select Project dialog box, select all the extensions that you configured in the localextensions.xml file.

Other tips from hybrids

If your Spring configuration does not load when the Hybris platform starts, the Spring file is probably not part of the CLASSPATH test. This may be caused by a missing project on the classpath or not including the resource folder in the Eclipse classpath. Make sure your .classpath file contains the following line: <classpathentry exported="true" kind="lib" path="resources"/>


Regarding your specific problem

It would be great to post MCVE because the problem might be regarding your specific test. The above tips may help you. Try to run the test successfully from hybrids before trying on your own.


Resources and Further Reading

Testing at SAP Hybris Commerce - Check out the Eclipse section

Eclipse Workspace Errors - Complete Guide - Contains More Resources for Fixing Eclipse Errors

Hybrid Testweb Frontend interface - if you want to test your tests from this interface, consider initializing junit tenant to

0
source

Source: https://habr.com/ru/post/1258803/


All Articles