aqa-tests icon indicating copy to clipboard operation
aqa-tests copied to clipboard

Add a Mockito Testcase

Open babsingh opened this issue 1 year ago • 5 comments

There are two OpenJ9 user issues where a crash with Mockito is reported:

  • https://github.com/eclipse-openj9/openj9/issues/18750
  • https://github.com/eclipse-openj9/openj9/issues/18781

The Mockito test case will help us identify the above crashes in our builds.

Test case variant 1: https://github.com/eclipse-openj9/openj9/files/13920987/reproApp.tar.gz

Test case variant 2: https://github.com/eclipse-openj9/openj9/files/13989201/segmentationerror.zip

Dependencies:

  • Mockito jar: https://repo1.maven.org/maven2/org/mockito/mockito-core
  • Bytebuddy
  • Maven

Not all dependencies might be needed; and test case variant 2 is simpler and relies on fewer dependencies.

Guidance based on the discussions with the test team:

  • The test should be added in https://github.com/adoptium/aqa-tests/tree/master/functional since it can be run with both OpenJ9 and OpenJDK.
  • We can create an folder MockitoTests.
  • We do not need testng in this case.
  • We need build.xml, playlist.xml, and the test case.
  • Sample example: https://github.com/eclipse-openj9/openj9/tree/master/test/functional/TestExample.
  • 3rd party jars should to be added in adoptium/TKG/scripts/getDependencies.pl#L66-L176.
  • Licences of 3rd party jars should be verified before including them into TKG:
    • Mockito: https://github.com/mockito/mockito/blob/main/LICENSE
    • Byte-buddy: https://github.com/raphw/byte-buddy/blob/master/LICENSE

babsingh avatar Feb 15 '24 22:02 babsingh

fyi @llxia

babsingh avatar Feb 15 '24 22:02 babsingh

@sophiaxu0424 Please take a look. Thanks

The test should be added under https://github.com/adoptium/aqa-tests/tree/master/functional The example can also be found at https://github.com/adoptium/aqa-tests/tree/master/functional/OpenJcePlusTests You will need to modify both aqa-tests repo and TKG repo.

llxia avatar Feb 22 '24 20:02 llxia

Hi @babsingh @llxia , having one question for me that how shall I update the command in the playlist.xml, for this Test case variant 1 and 2? My guessing was to dig into the two zip files to get the command details and as my next step, but I am not that too sure... I am seeing an example here from openJCEPlus test command, which has applied a text.xml:

<command>ant -f ${BUILD_ROOT}/functional/OpenJcePlusTests/test.xml -DTEST_JAVA=$(Q)$(JAVA_COMMAND)$(Q) launch_test; \
	$(TEST_STATUS)</command>
	
test.xml
testcase: launch_test
<echo message="Command: ${TEST_JAVA} -cp junit4.jar:hamcrest-core.jar:bcprov-jdk18on.jar:openjceplus-tests.jar --add-exports=java.base/sun.security.util=ALL-UNNAMED --add-exports=openjceplus/com.ibm.crypto.plus.provider.ock=ALL-UNNAMED ibm.jceplus.junit.TestAll" />

Would you please kindly advice some hints on how should I add it for mockito test case next? TIA!

sophiaxu0424 avatar Feb 28 '24 19:02 sophiaxu0424

mockito test case is attached in the above issue description.

llxia avatar Feb 28 '24 19:02 llxia

@sophiaxu0424 any progress on this issue?

llxia avatar Apr 08 '24 12:04 llxia

https://github.com/eclipse-openj9/openj9/issues/18781 is a dup of https://github.com/eclipse-openj9/openj9/issues/18750. The two test case variant are almost the same. The only difference is that one is directly invoke Mockito.mock(ArrayList.class); in main; and the other using junit to call Mockito.mock(Some.class);.

@babsingh is it necessary to add both cases?

llxia avatar May 17 '24 13:05 llxia

is it necessary to add both cases?

No. Adding one should provide the required coverage.

babsingh avatar May 17 '24 13:05 babsingh

@babsingh Thanks for clarifying.

llxia avatar May 17 '24 13:05 llxia

Test case variant 1 is added. We can close this issue. Thanks @sophiaxu0424

llxia avatar May 17 '24 13:05 llxia