Reputation: 61
I am able to execute test cases from hybris platform directory with 'ant alltests' command but not from eclipse.
Getting following errors while executing 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
Upvotes: 4
Views: 6079
Reputation: 20065
Actually with an hybris 6.1 and Eclispe Neon, I was able to run Junit tests from hybris projects without any troubles from the GUI.
To make tests work from Eclispe you have to ensure that
To fix last point, perform the following steps
An other tips from hybris
If your Spring configuration does not get bootstrapped at the startup of the Hybris Platform, the Spring file is probably not a part of test classpath. This can either be caused by a missing project at the classpath, or by not including your resources folder in the Eclipse classpath at all. Assure that your .classpath file contains the following line:
<classpathentry exported="true" kind="lib" path="resources"/>
It would be great to post a MCVE because the issue might be relative to your specific test. Above tips can help you. Try to successfully run a test from hybris before trying your own.
Testing in SAP Hybris Commerce - check Eclipse section
Eclipse workspace errors - A Complete guide - contains more resources to troubleshoot errors in Eclipse
The Hybris Testweb Frontend - if you want to test your tests from this interface, think about initializing the junit tenant
before
Upvotes: 1
Reputation: 1649
you will have to use ant from eclipse, (window > preferences > ant > runtime > ant home > and you specify where is your ant folder Eg: C:\Program Files\Ant\apache-ant-1.9.1
)
then (window > show view > Other > select ant)
then in your ant view click on add build files (on ant icon with +) this will show you all projects in your working set (platform extention must be imported) select platform/build.xml
.
in ant view you will see that all commands are shown, you can execute any operation from eclipse instead of command line.
Upvotes: 0