2

Currently we are using JUnit4 testing framework in our project with SAP Commerce 1808, and the unit tests are working fine.

However, we would like to start using JUnit5 framework. After importing respective JUnit5 libraries and compiling the unit test, I have run the command in the console:

ant unittests -Dtestclasses.packages=<package_name>  -Dtestclasses.suppress.junit.tenant=true

ant was not able to find the test class and showed the output in the console:

...

[echo] No tests found!

Which is surprising, because I have used the annotation @UnitTest before the class name:

@UnitTest
public class ClassName{
...
}

Trying to find an answer, I searched for examples of unit tests in SAP Commerce documentation: https://help.sap.com/viewer/d0224eca81e249cb821f2cdf45a82ace/1808/en-US/aae25ecb74ab4bd69cc5270ffd455459.html and noticed that all the unit test examples use only JUnit4 framework.

Also I checked Hybris out-of-the-box code and also saw that only JUnit4 framework is used there.

So the question is: how to run JUnit5 tests in SAP Commerce 1808?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • the problem is the Test Detection of the ant target. i had a running prototype of Junit5 vintage with hybris, where i could execute the tests via IDE. But the ant target it self is not detecting them, i assume this is connected with the Annotations, i would take a close look at what the ant target does, and also at the TestClassUtils, how they detect classes which should be executed. But i highly recommend to not modify internals of Hybris as this can cause upgrade pain. – Simon Schrottner Apr 20 '20 at 17:02

0 Answers0