This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 74167 - Wrong class path order set while running JUnit test via NB default ant scripts
Summary: Wrong class path order set while running JUnit test via NB default ant scripts
Status: RESOLVED FIXED
Alias: None
Product: apisupport
Classification: Unclassified
Component: Harness (show other bugs)
Version: 5.x
Hardware: All All
: P4 blocker (vote)
Assignee: rmichalsky
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-03-29 20:23 UTC by Girish Balachandran
Modified: 2009-11-24 19:06 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Girish Balachandran 2006-03-29 20:23:23 UTC
JUnit test ant script (nbbuild/templates/common.xml) sets the ordering of
runtime class path wrongly. Compiled junit test classes must be the first one in
the classpath list, but right now, its in the middle. So, if any user wanting to
have a  "Mock setup" of test classes to override implementation during test
scenario, mocked classes do not get picked.

This is a different behavior from XTest, which does the right thing. I had
checked in the fix for this, but was told to back out and file a bug.

"I would suggest to revert this unreviewed change and file your patch as a P2
issue against nbbuild, mention that the issue blocks 5.5 and add the
5.5_candidate status whiteboard. - Andrei"

The fix was in
http://nbbuild.netbeans.org/source/browse/nbbuild/templates/common.xml?r1=1.13.2.4.2.1&r2=1.13.2.4.2.2
Comment 1 Jesse Glick 2006-03-29 21:02:50 UTC
I agree that the behavior ought to be changed, if only for compatibility for
XTest. Also the CP order inside the IDE (ClassPathProvider) would need to be
reordered to match.

I would however rather not have such a change be in 5.5 because it is not in
apisupport 5.0u1 so we would either have to have the 5.0u1 harness != 5.5
harness (unacceptable) or put the patch in 5.0u1 (possible but very late to be
making such a change).

Why I do not consider this a priority, and suggest you do without it for 5.5: it
is generally undesirable to make mock impls of classes by physically replacing
the class anyway. You are then running a different version of the class from
what is actually in the module; you risk having a different signature; code
coverage tools, debuggers, and profilers will get confused; etc.

Generally such usages should be rewritten by either including minimal test hooks
in the real class; or using Lookup or a static package-private setter to inject
an alternate impl of pieces of logic which need to be mocked; or just making a
more flexible code architecture which splits functionality along interface lines
and makes pieces replaceable in general. There are various examples of doing
exactly this in existing unit tests in nb.org, which is why we did not ever need
to use a particular classpath order for running unit tests. I can provide
pointers to some examples if you need them.
Comment 2 Jesse Glick 2006-03-29 21:08:18 UTC
BTW 1.13.2.4.2.3 was not an exact reversion of 1.13.2.4.2.2 (check CVS manual
re. how to use up -j -j), rather it changed formatting of whitespace, so fixing
to be identical to 1.13.2.4.2.1:

Checking in common.xml;
/shared/data/ccvs/repository/nbbuild/templates/common.xml,v  <--  common.xml
new revision: 1.13.2.4.2.4; previous revision: 1.13.2.4.2.3
done
Comment 3 pzajac 2006-03-30 06:22:21 UTC
Jesse,
I heard talks that 50u1 harness has to be part of 5.5 harness... It is serious
problem for  developer who already has written tests:(. Yes it is late. But I am
not against to integrate to 50u1. 
Comment 4 rmichalsky 2008-11-24 15:07:02 UTC
Not into 7.0 or next release. Feel free to reopen if more important than it seems.
Comment 5 Quality Engineering 2009-11-02 10:57:46 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX
Comment 6 Jesse Glick 2009-11-23 14:17:17 UTC
Was still valid. Fixing: core-main #a573b72385dd
Comment 7 Quality Engineering 2009-11-24 19:06:18 UTC
Integrated into 'main-golden', will be available in build *200911241400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a573b72385dd
User: Jesse Glick <jglick@netbeans.org>
Log: #74167: build/test/unit/classes should come at front of ${test.unit.run.cp} to permit tests to override classes from the main module.