Abap
The execution entry for the ABAP CLASS Unit test, Class_setup, is hard-coded in the Unit Test framework implementation Cl_aunit_test_class.
The unit test method to be executed is returned to an inner table by Cl_aunit_test_class~get_test_methods, then loop the inner sheet and execute sequentially.
Java
The most commonly used maven plugin is maven-surefire-plugin, which can easily trigger unit tests individually or integrate the execution of unit tests into a sub-step of maven build.
Indicates that the following two test case (Srv/test/java/com/sap/testcase) was executed when MVN clean install was performed:
So how does Maven-surefire-plugin know which. The test methods in the Java file need to be executed?
To this directory, open the Maven-surefire-plugin implementation file Surefireplugin.class:
. M2\repository\org\apache\maven\plugins\maven-surefire-plugin\2.20\maven-surefire-plugin-2.20\org\apache\maven \plugin\surefire
Decompile, the answer is found in getdefaultincludes: All Java files that meet the suffix Test*.java, Tests.java, and Testcase.java end are candidates for performing unit tests.
The flexibility of unit testing in Java is that you can assign different category types to different methods in the same class:
Then use the command line MVN install plus parameter-P slowtests to perform only those methods of category slowtests:
For more advanced usage of @category annotations, refer to my SAP Community blog: Run only given sets of your unit test via @Category.
To get more original Jerry's technical articles, please follow the public number "Wang Zixi" or scan the QR code below:
Unit test for ABAP and Java