@RunListeners(value={CustomActionsRunListener.class,LangReferenceRemoverRunListener.class,ApplicationContextCheckRunListener.class,TransactionRunListener.class,ItemCreationListener.class,C2LSetupRunListener.class,TableSizeCheckRunListener.class,LogRunListener.class,ClassLoaderOverviewRunListener.class,PlatformRunListener.class,ResetMockitoRunListener.class,PlatformConfigurationCheckRunListener.class,VMBlockTimeRunListener.class,OpenDBConnectionRunListener.class,MemoryOverviewRunListener.class}) public abstract class HybrisJUnit4Test extends Object
HybrisJUnit4ClassRunner for test processing
and registers the PlatformRunListener for setting correct tenant and cluster of test system,
LogRunListener for logging all test runs and ItemCreationListener for assuring test isolation by
removing created items.
If you do not access the platform, you do not has to extend this class. Furthermore you can avoid extending this
class by activating the HybrisJUnit4ClassRunner using the RunWith annotation and by registering the
PlatformRunListener and at least one of ItemCreationListener/ TransactionRunListener using
the RunListeners annotation.
@RunWith(HybrisJUnit4ClassRunner.class)
@RunListeners(ItemCreationListener.class, PlatformRunListener.class)
public class MyHybrisJUnit4Test
{
@Test
public void myTest()
{
assertNotNull( C2LManager.getInstance().getBaseCurrency() );
}
}
If you want to add transactional support to your test cases (each platform change will be rolled back automatically),
see HybrisJUnit4TransactionalTest.
For using assert methods not provided by JUnit see the Assert class which can be imported static like the
org.junit.Assert of the junit framework.
| Modifier and Type | Field and Description |
|---|---|
protected Language |
defaultLanguage
Deprecated.
|
protected JaloSession |
jaloSession
Reference to current session.
|
| Constructor and Description |
|---|
HybrisJUnit4Test() |
| Modifier and Type | Method and Description |
|---|---|
void |
finish() |
static Currency |
getOrCreateCurrency(String isoCode)
Gets or creates (if not existent) currency to given iso code.
|
static Language |
getOrCreateLanguage(String isoCode)
Gets or creates (if not existent) language to given iso code.
|
void |
init()
Sets the current session and default language.
|
static boolean |
intenseChecksActivated()
returns true if property "test.intense.checks" is activated if active, then tests like -
ApplicationContextCheckRunListener (compares all beans before and after testrun) - TableSizeCheckRunListner (
compares ALL table sizes (SELECT COUNT) before and after testrun) are being executed
|
protected JaloSession jaloSession
@Deprecated protected Language defaultLanguage
public static boolean intenseChecksActivated()
public void init()
throws JaloSystemException
JaloSystemException - there was a security problem while creating the sessionpublic void finish()
throws JaloSecurityException
JaloSecurityExceptionpublic static Language getOrCreateLanguage(String isoCode) throws JaloSystemException
isoCode - iso code of languageJaloSystemException - thrown if language will be created but still existspublic static Currency getOrCreateCurrency(String isoCode) throws JaloSystemException
isoCode - iso code of currencyJaloSystemException - thrown if currency will be created but still existsCopyright © 2017 SAP SE. All Rights Reserved.