cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Is it possible to run unit tests within addons when running ant alltests or ant allwebtests?

Former Member
2,075

I have an addon which contains unit tests under /acceleratoraddon/web/testsrc. These tests run just fine when run from within an IDE, but they aren't picked up at all by either ant alltests or ant allwebtests. I'm using Hybris version 6.6.0.0.

I came across this 2014 post: https://answers.sap.com/questions/12750447/how-to-test-addon-controllers.html and attempted to implement the recommendation but it didn't work because the tests would't compile when copied to web/testsrc in the storefront extension. In addition to this, that directory is under source control so copying files there during the build is highly undesirable.

I am also aware of TestClassesUtil (invoked by ant), which scans the hybris environment for test classes on the classpath but I have been unsuccessful at getting it to pick up the tests in the addon.

Is there currently any way of getting the unit tests in an addon to run when invoking those ant targets?

Accepted Solutions (0)

Answers (3)

Answers (3)

sbouwers
Explorer
0 Likes

I struggle with the same problem, any solutions in the meanwhile?

Former Member
0 Likes

Did you solve the issue meanwhile?

Seems like I'm having the same Problem: Execute Unit Tests of AddOns and CommonWeb

Regarding the failing ant yunitweball and ant yunitweb within ${platformhome}/resource/ant --> It's because these Targets are deprecated and run into void (the name is undefined).

You can use ant allwebtests or ant unittests -Dtestclasses.web=true from within ${platformhome}

Nevertheless this will not solve the Problem as it only searches for Unit-Tests within web/testsrc which is in your case not enough (because the tests are located under /acceleratoraddon/web/testsrc)

Former Member
0 Likes

Hi Andrew,

Please check if ideas listed here are useful in your situation: https://experts.hybris.com/questions/93372/how-to-execute-web-unit-test-cases-in-the-addon.html

Hope this helps and Best Regards,

Former Member
0 Likes

Hi Jakub,

Thanks for your reply. I don't seem to have permission to view that page.

Former Member
0 Likes

Sorry, I copied the answer below:

You can use ant yunitweball from ${platformhome}/resources/ant folder, which runs all JUnit web tests; that is, all JUnit tests located at 'web/testsrc' folder of an extensions. You can see other avaliable commands by calling ant -p.

If it doesn’t help try using ant yunitupdate and ant yunitinit from ${platformhome} before trying again.

Regards,

Former Member
0 Likes

Hi Jakub,

Unfortunately this doens't work for me. I've run the ant yunitinit from ${platformhome} and then tried both ant yunitweball and ant yunitweb from ${platformhome}/resource/ant but both produce the following error:

${my-project-dir}/hybris/bin/platform/resources/ant/build.xml:76: Problem: failed to create task or type yunit_web Cause: The name is undefined. Action: Check the spelling. Action: Check that any custom tasks/types have been declared. Action: Check that any / declarations have taken place.

Oddly enough, the two targets are both listed when running ant -p