Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managed Classes and Triggers causing NullPointerException #1

Closed
banderson5144 opened this issue Oct 11, 2012 · 10 comments
Closed

Managed Classes and Triggers causing NullPointerException #1

banderson5144 opened this issue Oct 11, 2012 · 10 comments

Comments

@banderson5144
Copy link

Hey. I really like this tool. I think it is very useful for automating testmethods and seeing code coverage. There is only one problem I see with it so far. Managed Classes and Trigger from Managed Packages.

A test I ran to confirm this was to create a dev account and create some classes with some testmethods and no installed Packages. Your tool ran perfectly. However, when i installed "EasyDescibe", a managed package with no visibility to classes or triggers, when i ran the tool again i got a null pointer exception:

BUILD FAILED
build.xml:86: java.lang.NullPointerException
at com.force.jp.ant.apextestplus.TestResult.genCoverageResultsHtml(Unknown Source)
at com.force.jp.ant.apextestplus.TestResult.visualizeCoverageResults(Unknown Source)
at com.force.jp.ant.apextestplus.RunTestTask.execute(Unknown Source)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:392)
at org.apache.tools.ant.Target.performTasks(Target.java:413)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
at org.apache.tools.ant.Main.runBuild(Main.java:811)
at org.apache.tools.ant.Main.startAnt(Main.java:217)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

What i think maybe happening is this. When I ran the metadata API call to Salesforce to runAllTests, it kicked back a portion of XML that was referring to one of the managed classes and telling where exact lines were skipped:

01pE0000001fPVhIAM 0 75 0 -1.0 0 77 0 -1.0 0 88 0 -1.0 0 89 0 -1.0 0 90 0 -1.0 DescribeObjectCon EasyDescribe 50 5 Class

However, when you look at the actual class that was downloaded, the only thing inside of it was:

(hidden)

So i think the problem is when you are trying to highlight the missing Line number and you dont see it, it throws a null pointer exception.

The way Salesforce handles this in there UI is to not let the user see the Line missing Hit UI, they do not create a Hyperlink for the Code Coverage Percentage for managed classes or triggers.

I think if you just create a condition where if the class is managed or has "(hidden)" as its content, just report its code coverage percentage and not show the associated Debug log for it and not show the Line Graph thing, then you are in business.

Thanks I hope you can get this done soon!

@yebihara
Copy link
Owner

Thank you for your reporting the issue.
I'm happy to know that at least one person is using this tool! :-)

I'm going to try to reproduce and resolve it.
I'll be back later.

@banderson5144
Copy link
Author

Thanks very much. Sooner the better! :P

@banderson5144
Copy link
Author

Hey, I have one question. How would I set up this project in eclipse to use JIT debugging? Maybe I can take a crack at it.

yebihara pushed a commit that referenced this issue Oct 18, 2012
@yebihara
Copy link
Owner

I've resolved this issue.

Regarding JIT debugging, I've never used it and have no idea.
If you file a new issue and leave it open, someone else may find it and help you in the future...

@banderson5144
Copy link
Author

So looking through your code you basically did the same i did to get it to work (A couple of System.out.println showed me the root of the problem). Just one thing I want to mention though is that for the namespace you are only checking for null. I ran into a problem yesterday where I got an empty string for a namespace and null for the name of the class:

<codeCoverageWarnings>
<id>01qF0000000eglWIAQ</id>
<message>Average test coverage across all Apex Classes and Triggers is 24%, at least 75% test coverage is required.</message>
<name xsi:nil="true"/>
<namespace/>
</codeCoverageWarnings>

So in your ternary check, i would also do empty strings as well. But thanks again for looking into this and creating this wonderful tool!

Just one last question though, are you using the Metadata API call runTest or the Apex API call runTest?

yebihara pushed a commit that referenced this issue Oct 19, 2012
…esn't reach 75%, that was introduced by the previous fix for Issue #1.
@yebihara
Copy link
Owner

Good catch!
Thanks!

Just one last question though, are you using the Metadata API call runTest or the Apex API call runTest?

This software fully depends on classes that Force.com Migration Tool provides when it sends any request.
And I believe Metadata API is used.

@meramo64
Copy link

I recently downloaded ApexTestPlus. It is great...thanks you! I am however running into Null Pointer exceptions with certain classes (same as the issue above). Were there any updates applied to get around this issue? I am using version 30.0 (Spring 14).

Thanks

@yebihara
Copy link
Owner

Hi @meramo64 ,

Thank you for your feedback.
Can you give me the exact Java exception with call stack?
Also, since I'm not aware if your case is the same issue as this, I'm afraid I want you to open a new issue.

@meramo64
Copy link

Hi @yebihara,
Here is the exception I run into. I only get this with certain classes but I am thinking it might be the same as the issue above:

[apextestplus:runTest] java.lang.NullPointerException
[apextestplus:runTest] at java.util.TreeMap.getEntry(TreeMap.java:324)
[apextestplus:runTest] at java.util.TreeMap.get(TreeMap.java:255)
[apextestplus:runTest] at com.force.jp.ant.apextestplus.TestResult.separateDebugLog(TestResult.java:187)
[apextestplus:runTest] at com.force.jp.ant.apextestplus.RunTestTask.execute(RunTestTask.java:76)
[apextestplus:runTest] at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
[apextestplus:runTest] at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
[apextestplus:runTest] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[apextestplus:runTest] at java.lang.reflect.Method.invoke(Method.java:597)
[apextestplus:runTest] at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[apextestplus:runTest] at org.apache.tools.ant.Task.perform(Task.java:348)
[apextestplus:runTest] at org.apache.tools.ant.Target.execute(Target.java:435)
[apextestplus:runTest] at org.apache.tools.ant.Target.performTasks(Target.java:456)
[apextestplus:runTest] at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
[apextestplus:runTest] at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
[apextestplus:runTest] at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[apextestplus:runTest] at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
[apextestplus:runTest] at org.apache.tools.ant.Main.runBuild(Main.java:851)
[apextestplus:runTest] at org.apache.tools.ant.Main.startAnt(Main.java:235)
[apextestplus:runTest] at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[apextestplus:runTest] at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

BTW this tool looks really helpful and I hope to be able to test it further.
If you prefer I open a new case, please let me know.

Thanks!

@yebihara
Copy link
Owner

Hi @meramo64 ,

Thank you for your response.
As far as I see the stack trace, the NullPointerException is caused by a different problem.
So I filed a new issue, #2 .
Let's discuss further things on #2 .

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants