cancel
Showing results for 
Search instead for 
Did you mean: 

Executing unit tests in hybris 5

Former Member
0 Kudos

Hello,

We are having a set of unit tests annotated with @UnitTest throughout a number of custom extensions. We want to integrate those tests with our continuous integration builds.

My understanding is that the ant unittests target is what we need to use. The problem is that the ant unittests target actually tries to fire up the whole server using the junit tenant. This is kind of confusing since we are trying to run unit tests (which mock all of their dependencies) and not integration tests so I cannot understand why the ant unittests target tries to fire up the server. My understanding is that the target should really scan all extensions for unit tests annotated with the @UnitTest annotation, construct the correct classpath and execute the tests.

Can you please provide a guidance on how to execute our set of unit tests?

Best regards, Martin

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

We use the following ant script to execute the unit tests within the CI server: unittests.zip

You have to configure/change the following parts:

  • Property platformhome: Should be the path to the hybris platform directory

  • Property test.extensions: A list of extension names which should be tested, e.g. "customcore,customweb,custombackoffice" will test all unittests of customcore, customweb and custombackoffice

  • Property custom.extensions.directory: The directory name in which your custom extensions are located, e.g. "custom" if your extension are located within hybris/bin/custom//

update: Uploaded ZIP-File again

update: Uploaded ZIP-File which works for Hybris 6.5: unittests-65.zip

Former Member
0 Kudos

Hello Stefan,

Can this script be extended for integrationt tests too?

Thanks

0 Kudos

Hello Alexandra,

unfortunately not because the hybris integration tests need a running hybris instance. For that you could use the out-of-the-box functionality of hybris: ant integrationtests

kind regards Stefan

Former Member
0 Kudos

I cannot download the file 😞 Can you uploaded again?

Former Member
0 Kudos

Hello Stefan,

In our project we need to do the same thing. Could you please share your script once again as I'm unable to download the existing one.

Thanks in advance!

0 Kudos

I've uploaded the ZIP file once more (hopefully it's not deleted again)

Answers (7)

Answers (7)

Former Member
0 Kudos

Since 6.4 you can use

 ant unittests -Dtestclasses.suppress.junit.tenant=true .....
Former Member
0 Kudos

Does anybody know whether this solution works for Hyris version 6?

I tried running this for Hybris Version 6 and am getting NoClassDefFoundError error. Has anyone else faced the same issue?

0 Kudos

Hi Ajith,

I've updated the unittests to work with Hybris 6.5 and 6.6. The file is added to my original answer.

Hope this helps, Stefan

Former Member
0 Kudos

Thank you for looking into this Stefan. I'll give this a try!!!

Former Member
0 Kudos

Enhanced testing.xml

  • works with hybris-5.4

  • restricted to unittests in custom extensions

Former Member
0 Kudos

Is this file still available?

Former Member
0 Kudos

We successfully use "ant unittest". Wasn't an easy one, to get this started.

One key advance was to limit the annotation scanner to our own packages with -Dtestclasses.packages=....

The second learning was that some code needed refactoring, because typically Config.get... or misc. Util.classes fire up a server. It's indeed not easy to figure out where this comes from.

At least you can find out which unit test launches the tenant, then run it in your IDE with debugging and pause the thread once you see tenant araising.

Good luck!

0 Kudos

We created our own ant script which executes the JUnit-Tests without running the hybris server. We did this because the hybris way using ant unittests takes 25 minutes to execute all unit tests. Our own script takes about 3 minutes to execute exactly the same unit tests with the same result.

Starting the hybris server brings you even more problems, not only the extensive runtime. If you need to have the AspectJ weaving enabled for your system to start, you are executing the unit tests on classes which have been weaved. That's usually not what somebody wants to have because with that you are testing more than just he class/method.

It would be cool if Hybris solves the mentioned JIRA Ticket! If somebody is interested in our script, just give me a short hint.

Former Member
0 Kudos

Hi Stefan, I would be grateful if you are able to share your Ant script with me. I am particularly interested in the mechanism that you use to bootstrap the classpath for the tests execution.

0 Kudos

Can you share the script please.

Former Member
0 Kudos

Unfortunately, from what I see the ticket is in a JIRA that is no longer supported.

Can we have an official statement for this question by Hybris as based on the watch list quite a few people are interested into it.

Former Member
0 Kudos

There was a JIRA-ticket which exactly describes this problem.
I'm also interested in getting the hybris4 behavior back!