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 2019/05/17 09:04:01 UTC

[Bug 63446] New: JUnitLauncher Task with and will create a listener per testcase wrongly

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

            Bug ID: 63446
           Summary: JUnitLauncher Task with <testclasses> and <fork> will
                    create a listener per testcase wrongly
           Product: Ant
           Version: 1.10.6
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Optional Tasks
          Assignee: notifications@ant.apache.org
          Reporter: mseele@guh-software.de
  Target Milestone: ---

When using the following task

<junitlauncher>
    <testclasses outputdir="output_dir">
        <zipfileset src="tests.jar">
            <include name="**/*Test.class"/>
        </zipfileset>
        <listener type="legacy-xml" sendSysOut="true" sendSysErr="true" />
        <fork includeJUnitPlatformLibraries="false">
           <!-- jvm args -->
        </fork>
    </testclasses>
    <classpath>
        <fileset file="tests.jar" />
    </classpath>
</junitlauncher>

the LegacyXmlResultFormatter will be created and executed as often as tests are
found by testclasses/zipfileset. 
This results in crappy xml-files because they will be overridden multiple times
and can have endings like "</testsuite>e>e>" because it happens in parallel.

E.g. if zipfileset finds 100 Test Classes, for each test class 100
LegacyXmlResultFormatter instances are created and executed. 
If zipfileset finds 10 Test Classes, for each test class 10
LegacyXmlResultFormatter instances are created and executed.

This is wrong, there should be only 1 LegacyXmlResultFormatter instance created
per test class.

The bug happens in
org.apache.tools.ant.taskdefs.optional.junitlauncher.confined.TestClasses.fromForkedRepresentation(XMLStreamReader)
where 1 testDefinition is created for all found tests.

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

Lance Hankins <lh...@motio.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |major

--- Comment #5 from Lance Hankins <lh...@motio.com> ---
For what its worth - this seems like it should a higher priority bug, as it
will certainly prohibit anyone attempting to use Junit5 via <junitlauncher> and
<fork> from being successful. 

We just recently upgraded to Junit5 and then also had to upgrade to Ant 1.10.6,
so that we could use <fork> with <junitlauncher>.

We have configured: 

   <listener type="legacy-xml" sendSysOut="true" sendSysErr="true"/>

I spent much of the day trying to figure out why we get spurious extra
characters at the end of some of the generated JUnit results XML files.  For
our smallest module, we have about 90 tests (spread across 11 test classes) and
I was getting on average 2-4 corrupt XML files each time I ran all the tests in
this module (each corrupt file would have 1-2 extra characters after the last
XML tag, like "e>").   

This meant that <junitreport> would then complain about corrupt XML files when
it was trying to generate the HTML report, and then the affected test classes
would be left off of the HTML report, e.g. : 

   [junitreport] [Fatal Error] TEST-com.acme.CmdLineParserTest.xml:227:26:
Content is not allowed in trailing section.
   [junitreport] The file
/work/proj/build/test/data/TEST-com.acme.CmdLineParserTest.xml is not a valid
XML document. It is possibly corrupted.


I finally stumbled across this ticket and was very happy to see that Michael
had narrowed down the issue and submitted a fix (thanks Michael!)

That said - the fix hasn't made it to any released Ant distribution yet, so
anyone trying to use 1.10.6 in order to support JUnit5 with <fork> is likely
going to be banging their head on the same issue. 

I ended up doing the following in order to temporarily work around my issue
(hopefully with no ill side-effects): 
 1. pulled down the 1.10.7alpha nightly build (#1114 ) from:
https://builds.apache.org/job/Ant_Nightly/
 2. updated my 1.10.6 ant distribution to replace the original
lib/ant-junitlauncher.jar with the same jar from the nightly build

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

--- Comment #6 from Stefan Bodewig <bo...@apache.org> ---
The bug has already been fixed in Ant's master branch, you may want to try a
nightly build (see https://bz.apache.org/bugzilla/show_bug.cgi?id=63446#c2 ).

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

--- Comment #7 from Stefan Bodewig <bo...@apache.org> ---
sprry, I should have read to the end of your comment.

I completely agree this is a real problem for users migrating to JUnit5 using
the XML formatter.

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
   Target Milestone|---                         |1.10.7
                 OS|                            |All
         Resolution|---                         |FIXED

--- Comment #2 from Jaikiran Pai <ja...@apache.org> ---
Thank you for reporting this issue. This indeed is a bug. Thank you also, for
taking the efforts to narrow this down and creating a patch. I've used your
patch, done some minor adjustments to it and merged it upstream[1]. My local
tests with this patch have went fine. I haven't had the time to add new tests
to verify this fix, but looking at the change you did, the fix makes sense. 

If you want to give this a try, you can get our nightly builds[2] and see how
it goes for you in your project. 

P.S: We add the names of our contributors to a contributors file that we
maintain in the project. If you tell me the first and last name by which you
would like to be listed, I will go ahead and add your name in there.

[1]
https://gitbox.apache.org/repos/asf?p=ant.git;a=commitdiff;h=03a718d88dbc5c15e2085eaa292b160c8608b998
[2]
https://builds.apache.org/job/Ant_Nightly/lastSuccessfulBuild/artifact/distribution/

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

--- Comment #3 from mseele@guh-software.de ---
I've tested Ant_Nightly #1088 and can confirm that the bug is gone.

My fullname is "Michael Seele", you can add it to the contributors file.

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

--- Comment #1 from mseele@guh-software.de ---
Created attachment 36592
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36592&action=edit
PATCH with bugfix

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

Lance Hankins <lh...@motio.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lhankins@motio.com

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

--- Comment #8 from Jaikiran Pai <ja...@apache.org> ---
Agreed too. I will try and find some time in this coming week and finish off
the pending commits (related to Java 9+ issues) and propose a new release.
Sorry about the delay.

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

[Bug 63446] JUnitLauncher Task with and will create a listener per testcase wrongly

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

--- Comment #4 from Jaikiran Pai <ja...@apache.org> ---
Thank you for verifying the nightly build.

> My fullname is "Michael Seele", you can add it to the contributors file.

Done
https://gitbox.apache.org/repos/asf?p=ant.git;a=commitdiff;h=1cb2f8175077b1a61763bb5e24a120c98c576180

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