Hi, The junitlauncher does not identify and execute unit test which uses mocking framework Mockito. The other unit test cases which are not using the mocking framework are identified and executed successfully. Also, the IntelliJ Idea IDE successfully executes the unit test which uses mocking framework Mockito. Execution Log: [junitlauncher] Test run finished after 0 ms [junitlauncher] [ 1 containers found ] [junitlauncher] [ 0 containers skipped ] [junitlauncher] [ 1 containers started ] [junitlauncher] [ 0 containers aborted ] [junitlauncher] [ 1 containers successful ] [junitlauncher] [ 0 containers failed ] [junitlauncher] [ 0 tests found ] [junitlauncher] [ 0 tests skipped ] [junitlauncher] [ 0 tests started ] [junitlauncher] [ 0 tests aborted ] [junitlauncher] [ 0 tests successful ] [junitlauncher] [ 0 tests failed ] Environment: OS: Winodws 10 and Centos 7 IDE: IntelliJ Idea 2019.1.3, 2020.1 ANT: 1.10.5 Mockito: 3.3.3 JDK: OpenJDK 1.8 Code: @ExtendWith(MockitoExtension.class) class FileHandlerTest { @Mock ServletContext application; @Test void getLegacyStaticFilePath() { FileHandler underTest = new FileHandler(); when(application.getAttribute("envglobal")).thenReturn("windev"); Map<String, String> filePathMap=underTest.getLegacyStaticFilePath("csv",application); assertAll("static file path", () -> assertEquals("C:\\gta\\supportive_documents\\", filePathMap.get("supportDoc")), () -> assertEquals("C:\\gta\\gtc_load\\", filePathMap.get("loadDoc")), () -> assertEquals("C:\\gta\\ttg_reports\\", filePathMap.get("ttgReportsDoc"))); } } Other Observation: Test report TEST-com.XXX.FileHandlerTest.txt created with 0 byte.
Would you be able to attach a simple build.xml file which will help us reproduce this issue easily?
Here is the build step which invokes the JUnit <!-- Run Unit Tests and Generate Report --> <target name="test.junit.launcher" depends="compile.module.goda1.production"> <echo message="Launcher Started" /> <mkdir dir="${test.report.dir}" /> <junitlauncher haltOnFailure="true" printSummary="true" > <classpath> <!-- the test classes themselves --> <pathelement location="${goda1.testoutput.dir}"/> <pathelement location="${goda1.output.dir}"/> </classpath> <testclasses outputdir="${test.report.dir}"> <fileset dir="${goda1.testoutput.dir}"> <include name="**/*Test.class"/> </fileset> <listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/> <listener type="legacy-plain" sendSysOut="true" /> </testclasses> </junitlauncher> </target> The ${goda1.testoutput.dir} represents compiled output of the test classes and the ${goda1.output.dir} represents the compiled output of the project source code.
Thank you for that build snippet. I just gave this a quick try locally and was able to see that the test runs fine. I noticed in your output that you are using Ant 1.10.5 release. Could you try this against the latest released 1.10.8 (the version I tried against) and see if it works there?
Yes, I am using ANT 1.10.5 and also mentioned that at the time of raising defect. Going through your response, does that mean ANT 1.10.5 doesn't recognize unit test written using mocking framework MOckito 3.3? Is it a Bug? Also, I gave a try using ANT 1.10.8 having the same structure and got below error: failed to launch in-vm tests.
Can anyone please look into this? Appreciate earliest resolution. Thanks.