It would appear the solution is to write unit test vis descending from
AbstractConventionTaskTest....


On Thu, Jun 16, 2011 at 11:35 AM, phil swenson <[email protected]> wrote:
> I'm on gradle 1.0 m3.  I was trying to write a unit test for one of my
> gradle tasks and get an NPE on creation.
>
>
> Basically this call:
>  L10NJarTask task = new L10NJarTask()
>
> caused this:
>
> java.lang.NullPointerException
>        at 
> org.gradle.api.internal.AbstractTask$TaskInfo.access$000(AbstractTask.java:421)
>        at org.gradle.api.internal.AbstractTask.<init>(AbstractTask.java:105)
>        at org.gradle.api.internal.AbstractTask.<init>(AbstractTask.java:95)
>        at org.gradle.api.DefaultTask.<init>(DefaultTask.java:31)
>        at com.softwareag.bas.plugins.L10NJarTask.<init>(L10NJarTask.groovy)
>        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 
> Method)
>        at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
>        at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
>        at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
>        at 
> org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
>        at 
> org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
>        at 
> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:52)
>        at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
>        at 
> org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:194)
>        at 
> com.softwareag.bas.plugins.L10PluginTest.testCreateResourceJar(L10PluginTest.groovy:176)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>        at 
> com.intellij.junit3.JUnit3IdeaTestRunner.doRun(JUnit3IdeaTestRunner.java:139)
>        at 
> com.intellij.junit3.JUnit3IdeaTestRunner.startRunnerWithArgs(JUnit3IdeaTestRunner.java:52)
>        at 
> com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:199)
>        at 
> com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:62)
>        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>        at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>        at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
>
> So looking at the gradle code, it appears any descendants of
> DefaultTask should not be constructed directly.  So in this case, how
> should I construct?  And how would I get a handle to the instance so I
> can test it?
>
> Do I need to do a full integration test?
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to