Hi,
the return value of helperMethod() in your example is of type void. this does not fit your asserEquals call in your tests. Refactoring helpermethod to:
---------

public String helperMethod(){
    "helper method called"
}

---------
should do the trick.

regards,
René

Am 28.09.11 22:19, schrieb tseredz:
Thanks Rene. Here's my example:

Here's MyCustomTask implementation:

class MyCustomTask extends DefaultTask
{
     @TaskAction
     def runTask()
     {
         println "main task ran";
         helperMethod()
     }

     public void helperMethod()
     {
         println "helper method called"
     }
}


And here's the test class from where I'm trying to call helperMetho()

class MyCustomTaskTest extends GroovyTestCase
{
     void testHelperMethod()
     {
         Project project = ProjectBuilder.builder().build()
         def sut = project.task('newTask', type: MyCustomTask)

         assertEquals("helper method called", sut.helperMethod())
     }
}


sut.helperMethod() obviously does not work. So, how can I call
helperMethod() on my "sut" object?

--
View this message in context: 
http://gradle.1045684.n5.nabble.com/How-to-Unit-Test-protected-public-methods-in-the-CustomTask-tp4850331p4850601.html
Sent from the gradle-user mailing list archive at Nabble.com.

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

     http://xircles.codehaus.org/manage_email




--
-----------------------
regards,
René

rene groeschke
http://www.breskeby.com
@breskeby


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

   http://xircles.codehaus.org/manage_email


Reply via email to