Hybris provides a basic infrastructure for your unit and integration tests. To write meaningful tests with deterministic results the following recommendations should be used.

Since Hybris 4.4

Suppose you want to run the tests in the package de.coreservices.strategies.impl. Then your tests must have one of the annotations @UnitTest, @IntegrationTest, @DemoTest, @PerformanceTest or @ManualTest and you can type:

ant clean all alltests -Dtestclasses.packages=de.coreservices.strategies.impl.*

 This will run tests in the folder testsrc of your extension. If you want to run the tests of the folder web/testsrc, you must use:

ant clean all allwebtests -Dtestclasses.packages=de.coreservices.web.converters.impl.*


This way of starting the tests ist deprecated and in Hybris 5.3 the ant target was removed. Please read:
Testing in the hybris Multichannel Suite

Today Eclipse crashes every time a try to run a unit test and Intellij compiles the whole Hybris project but doesn't start the Unit test runner.
So I decided to run my test using ant:

ant clean all yunit -Dtest=de.sample.coreservices.services.impl.PriceRowBasedEnergyPriceServiceTest

With the parameter test you can choose a test to run. Unfortunately you cannot run two or more tests.

Based on Hybris 4.8.14, 5.7

When finding errors in complex integration tests, it is useful to start the HMC or other extension on the junit tenant to check what data is stored there.

When you are building a unitary test you may need to assert the value given to a setter. By default all the setters of a mock object (with Mockito) do nothing.

When creating integraton tests it is essential to understand how Hybris manages o emulates transactions inside tests.