Hey,

In your code, I don't see why afterEvaluate hooks should be triggered
:) afterEvaluate is a part of build lifecycle and it does not seem you are
running any build in your test. If your plugin is using the afterEvaluate
hooks you should probably look at testing the plugin logic at a higher
level, e.g. via GradleExecuter.

Hope that helps!

On Tue, Sep 13, 2011 at 8:50 AM, Ingo Richter <[email protected]>wrote:

> Hi,
>
> Probably a quick question:
> I wrote some tests for the plugin I'm working on. The plugin calls some
> methods in the afterEvaluate closure. This works fine, when I use the plugin
> in my project.
> In my testcase however, it seems that the afterEvaluate closure doesn't get
> called and therefore my testcase fails verifying some of the properties that
> are set by one of the called methods.
>
> Here is the part that currently fails for me:
>
> project = ProjectBuilder.builder().build()
>
>     def "FLEXHOME is not provided"(Project project) {
>         project.plugins.apply(GradleFxPlugin)
>         GradleFxPlugin plugin = project.plugins.getPlugin(GradleFxPlugin)
>
>         expect:
>         ! plugin.isFlexHomeProvided()
>         // TODO: why is there no ant.properties collection available?
> afterEvaluate doesn't get called during the testrun
>         project.ant.properties['FLEX_HOME'] ==
> plugin.flexSDKLocalCacheDir('4.5.1.21328')
>
>         where:
>         project << createProjectWithoutFlexHome()
>     }
>
> Is there a better approach to test the project configuration, when the
> properties are added by a method that gets called in afterEvaluate?
>
> Thanks,
> Ingo
> --
> San Francisco Blog <http://8880km.blogspot.com>
> "today is tomorrows past blog" <http://ingorichter.blogspot.com>
> LinkedIn Profile: <http://www.linkedin.com/in/ingorichter>
> twitter: <http://twitter.com/ingorichter>
>
>


-- 
Szczepan Faber
Principal engineer@gradleware
Lead@mockito

Reply via email to