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 166561 - Cannot profile unit test suites
Summary: Cannot profile unit test suites
Status: RESOLVED FIXED
Alias: None
Product: profiler
Classification: Unclassified
Component: Base (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: J Bachorik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-04 15:50 UTC by tboerkel
Modified: 2011-08-05 14:39 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
ide log (31.92 KB, text/plain)
2009-06-04 15:51 UTC, tboerkel
Details
Project files (14.25 KB, application/x-compressed)
2009-06-08 07:28 UTC, tboerkel
Details
Full working repro (130.79 KB, application/x-compressed)
2009-06-08 13:49 UTC, tboerkel
Details

Note You need to log in before you can comment on or make changes to this bug.
Description tboerkel 2009-06-04 15:50:58 UTC
I cannot profile a unit test suite with NB 6.5 and 6.7 RC1.

I can do "Profile file" on a unit test class, but with a suite I get:

init:
profile-init:
deps-jar:
compile-single:
profile-single:
Profiler Agent: Waiting for connection on port 5140, timeout 10 seconds (Protocol version: 9)
Profiler Agent: Established local connection with the tool
java.lang.NoClassDefFoundError: com/apag/p2plus/p2businessevaluation/P2businessevaluationSuite
Caused by: java.lang.ClassNotFoundException: com.apag.p2plus.p2businessevaluation.P2businessevaluationSuite
        at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Profiler Agent: Connection with agent closed
Could not find the main class: com.apag.p2plus.p2businessevaluation.P2businessevaluationSuite.  Program will exit.
Profiler Agent: Connection with agent closed
Profiler Agent: Initializing...
Profiler Agent: Options: >D:\Program Files\NetBeans 6.7 RC1\profiler3\lib,5140,10<
Profiler Agent: Initialized succesfully
Exception in thread "main" Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)


The Profile | Profile Other | Profile Test for [classname] action of course does not help, because a suite has no
corresponding "normal" class.

Attaching ide.log drom NB 6.7 RC1.
Comment 1 tboerkel 2009-06-04 15:51:30 UTC
Created attachment 83214 [details]
ide log
Comment 2 J Bachorik 2009-06-05 13:33:08 UTC
Are you deploying your project to an application server. If yes then which one? Could you describe your setup closer?

I tried to reproduce the problem on a J2SE project but without success. It either works (for JUnit3 suite) or informs
the user abut the fact that the operation is not supported (for JUnit4 suite).
Comment 3 tboerkel 2009-06-05 13:52:38 UTC
No, it's a J2SE project and we are using JUnit 3. Should I attach the project (without sources)?
Comment 4 J Bachorik 2009-06-05 13:54:16 UTC
That would be perfect!
Comment 5 tboerkel 2009-06-08 07:28:57 UTC
Created attachment 83294 [details]
Project files
Comment 6 J Bachorik 2009-06-08 12:08:32 UTC
I can not reproduce it whatever I do. If you try the same action with a new userdir and/or project, does it happen?
Comment 7 Jiri Sedlacek 2009-06-08 12:10:52 UTC
Product Version: NetBeans IDE 6.7 RC2 (Build 200906042131)
Java: 1.6.0_14; Java HotSpot(TM) Client VM 14.0-b16
System: Windows Vista version 6.0 running on x86; Cp1252; en_US (nb)

Wasn't able to reproduce, profiling JUnit 3.x suite works fine for me. The attached project doesn't help - there are no
sources, no tests, just missing dependencies on external modules.
Comment 8 tboerkel 2009-06-08 13:49:06 UTC
I have made a full working repro. Just do "Profile file" on the SampleSuite class. Attaching the repro...
Comment 9 tboerkel 2009-06-08 13:49:50 UTC
Created attachment 83316 [details]
Full working repro
Comment 10 tboerkel 2009-06-08 13:51:01 UTC
Regarding new user dir: It does not work with NB 6.5 and it does not work with NB 6.7 RC1 with new user dir.
Comment 11 J Bachorik 2009-06-08 14:18:24 UTC
Thanks Thomas,
thanks for the project. I was able to reproduce and identify the problem.

The root cause is a main method in your test suite. It gets confused with a normal class and mixes up classpaths. The
easy workaround is to remove the main method and add the tests to the suite in its constructor instead.

A test suite generated by IDE works fine and the problematic case is pretty easy to workaround so I am lowering the
priority.
Comment 12 J Bachorik 2011-07-04 12:33:32 UTC
Fixed.

Added few additional conditions for "profile as test" action - http://hg.netbeans.org/profiler-main/rev/b5a4968c630a
Comment 13 Quality Engineering 2011-08-05 14:39:09 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/b5a4968c630a
User: Jaroslav Bachorik <yardus@netbeans.org>
Log: #166561: Cannot profile unit test suites