You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bu...@apache.org on 2020/07/13 06:05:46 UTC

[Bug 64597] New: junitlauncher does not identify and execute unit test which uses mocking framework Mockito

https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

            Bug ID: 64597
           Summary: junitlauncher does not identify and execute unit test
                    which uses mocking framework Mockito
           Product: Ant
           Version: 1.10.5
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
          Assignee: notifications@ant.apache.org
          Reporter: mgandhi@sscinc.com
  Target Milestone: ---

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

--- Comment #2 from mgandhi@sscinc.com ---
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

--- Comment #3 from Jaikiran Pai <ja...@apache.org> ---
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?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

--- Comment #5 from mgandhi@sscinc.com ---
Can anyone please look into this? Appreciate earliest resolution.

Thanks.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

--- Comment #4 from mgandhi@sscinc.com ---
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

Jaikiran Pai <ja...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from Jaikiran Pai <ja...@apache.org> ---
Would you be able to attach a simple build.xml file which will help us
reproduce this issue easily?

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

Jaikiran Pai <ja...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #6 from Jaikiran Pai <ja...@apache.org> ---
I've tried to reproduce this against latest released Ant versions but haven't
been able to reproduce this. If you are still running into this problem, please
let us know if there is any way you can share a latest reproducer for this that
fails against our latest released Ant version (1.10.11)

-- 
You are receiving this mail because:
You are the assignee for the bug.

[Bug 64597] junitlauncher does not identify and execute unit test which uses mocking framework Mockito

Posted by bu...@apache.org.
https://bz.apache.org/bugzilla/show_bug.cgi?id=64597

Jaikiran Pai <ja...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WORKSFORME
             Status|NEEDINFO                    |RESOLVED

-- 
You are receiving this mail because:
You are the assignee for the bug.