How to run JUnit5 tests in SAP Commerce 1808 - junit4

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?

Related

Cannot "Run as JUnit Plug-in test" on test plugin/package (JUnit5)

I'm trying to add JUnit5 support in my Eclipse RCP application. It almost works, because for now I can:
Use Maven to build whole application and run tests with Tycho
Run single JUnit5 tests (creating run configuration on specific class) in
Eclipse
Run single JUnit5 tests in Run as JUnit Plug-in test mode in Eclipse
Run multiple JUnit5 tests in Run as JUnit test mode in Eclipse
What I'm trying to achieve now is to be able to run whole sets of test classes in plug-in test mode. For JUnit4-based plug-ins I could simply right-click on whole package or even whole plug-in and invoke Run As -> JUnit Plug-in test.
When I do the same operation on JUnit5 tests I get an error: No tests found with test runner 'JUnit 5'.
My current configuration for such plug-ins looks as follows:
According to official instructions in MANIFEST.FM I have Import-Package dependencies:
org.junit.jupiter.api,
org.junit.jupiter.params,
org.junit.jupiter.params.provider
and org.junit as Require-Bundle dependency
In order to run tests in Eclipse IDE I've also added JUnit 5 library to Java Build Path of the plugin. I coudn't add JUnit 5 runner dependencies to MANIFEST.FM instead, because of conflict with Tycho.

How to run single spec2 test with maven?

I have a scala class with several spec2 tests in it and maven as build tool. I can't find how I can launch one single spec2 test using maven. Is it possible at all?

How to run all Specs2 tests under IntelliJ IDEA?

In my Scala project, my Specs2 tests are structured as follows:
src/test/scala
-> my.package
---> my.package.sub1
------> SomeTest1
------> SomeTest2
---> my.package.sub2
------> SomeTest3
I'm using SBT to build all of this, and I can use sbt test to run all tests in my package.
I'd like to use IntelliJ IDEA's built-in Specs2 run configuration support. I point it to use all tests in my.package.
Running this yields the error message Error running <run config name>: Not found suite class. It cannot find Specs2 test suites. IDEA runs my tests if I point it to a subpackage.
How do I configure IDEA to look in all packages and run all the test suites it finds?
I've managed to run all my Specs2 tests in IDEA 13.1.4 and the more recent 14.0.1 using All in package for Test kind and In whole project or In single module for Search for tests. I left Test Package field empty.
I had to create this configuration manually.
You may want to use Ctrl+Shift+F10 to create a Specs2 configuration and then modify it accordingly.

Error when generating unit test on Activiti

When I'm trying to do activiti BPM when i'm running "Generate a unit test" i'm getting error in Java file that created when running unit test
i'm using eclipse juno and fedora OS
You need to add junit library to your project.
properties->java build path->libraries->add libary

Powermock and problem loading jar file file during unit test with JUnit 4 in eclipse

I am using powermock 1.2.5 to perform a class that saves data into Oracle database. When I run my test my unit test fails with the following exception:
NoSuchAlgorithmException : DES Algorithm can be found.
After debugging the code I found out that this exception is thrown when my application is trying to set the password to establish a database connection.
Some of my observations are:
If I run my unit test without power mock , then the exception does not occur.
I manage to run the unit test if I manually include the sun-jce.jar file into the unit test bootstrap in eclipse.sun-jce.jar is one of the jar file within jre library folder. I am using SUN java jre version 1.5.0_10
So I am guessing that somehow power mock unloads this particular jar file during unit test runtime. Does any one encounter similiar problem when using powermock ?
A work around that I am thinking at the moment is to load the jar file programmatically under the setup() of my unit test.
Manage to resove this problem. It seems PowerMock loads its own crypto library. So if we add ignore the javax.crypto when we run power mock: #PowerMockIgnore({"javax.crypto" }), the test will work.