hauner / grails-cucumber

a Cucumber plugin for Grails
https://github.com/hauner/grails-cucumber
63 stars 35 forks source link

Grails 2.3 Support #31

Closed beckje01 closed 10 years ago

beckje01 commented 11 years ago

The plugin is not currently working with grails 2.3, the _Event script doesn't work as is and I can't get the plugin project to upgrade and work on its own either.

hauner commented 11 years ago

Hi Jeff,

after some fiddling with IDEA and updating BuildConfig.groovy, I'm able to build and debug/run the plugin from IDEA again. At least something ;-)

Unfortunately my Book sample doesn't run with 2.3 anymore. The example fails because something that was in the binding is not there anymore. I have to dig into grails to find out what is going on.

Not sure that this the only problem.. the fork-mode changes sound pretty significant.

beckje01 commented 11 years ago

If you got things building in 2.3 I can take a look.

hauner commented 11 years ago

Thanks for the offer to help :-)

I have created a grails-2.3.0 branch.

The plugin itself and the test/projects/Book sample are using grails 2.3.0 now. I had to clean/compile the plugin a couple of times before the unit test did run again.

The Books sample fails in grails.plugin.cucumber.Hooks because it tries to use the 'appCtx' variable from the script binding. Which is null with 2.3.0. Not sure if it was renamed, deleted or is just not set at the right time anymore.

hauner commented 11 years ago

I made a small change (7feecac844a7b7636783fc925bef34568fef09e5) that fixes the Books example in non-forked mode. It simply adds appCtx manually.

In forked-mode grails fails early, complaining that the script has no property includeTargets at the beginning of the plugins _Events.groovy.

hauner commented 11 years ago

Looking at grails jira, forked mode has a number of issues. So the includeTargets problem hast to be fixed in grails.

beckje01 commented 11 years ago

Thanks for the work I'm going to pull this in as a inline plugin and see how it works.

beckje01 commented 11 years ago

Trying to run test-app on my local box with the grails 2.3 branch is giving me the following:

| Error Fatal error running tests: org/junit/internal/AssumptionViolatedException (Use --stacktrace to see the full trace) | Compiling 12 source files.. | Tests FAILED - view reports in /Users/jeffbeck/projects/grails-cucumber/target/test-reports | Error Error executing script TestApp: org/junit/internal/AssumptionViolatedException (Use --stacktrace to see the full trace)

hauner commented 11 years ago

Does the stacktrace show anything useful?

beckje01 commented 11 years ago

Not really I'm gonna use a vagrant vm to set up a clean environment to see if its just my box.

beckje01 commented 11 years ago

I got it working in a clean environment built as 0.10.0-SNAPSHOT and a local maven-install, I'll be digging into it more Thanks for all the help!

graemerocher commented 11 years ago

The includeTargets issue is present because in forked mode, Gant is not present, so Gant methods and targets cannot be run in forked mode. I don't think this is fixable, however the plugin could be made to work without requiring to include _GrailsCompile. What do you need from that script?

hauner commented 11 years ago

The original reason was http://jira.grails.org/browse/GRAILS-6453 based on this discussion http://grails.1312388.n4.nabble.com/plugin-classes-not-included-in-classpath-for-plugin-scripts-td2271962.html

Quick version is, I am using a custom test type and to avoid a ClassNotFoundException I have to compile and soft load it. This is based on https://github.com/spockframework/spock-grails/blob/master/spock-grails/plugin/scripts/_Events.groovy

Apart from that my Event.groovy does have a few lines to compile cucumber groovy step files files from "non standard" test folders.

graemerocher commented 11 years ago

To avoid using the Gant scripts for compilation you can use GrailsProjectCompiler directly:

https://github.com/grails/grails-core/blob/master/grails-core/src/main/groovy/org/codehaus/groovy/grails/compiler/GrailsProjectCompiler.groovy

Should just be a matter of

projectCompiler = new GrailsProjectCompiler(pluginSettings, classLoader)

And then compileAll()

nwittstruck commented 10 years ago

I just saw in the release notes that the next version of the plugin will not work with grails 2.3 - what's still open? Everything is working fine for us, so I'm just wondering.

hauner commented 10 years ago

That's surprising.. :)

Last time I checked (guess it was 2.3.0) it did not work. Maybe they fixed it for me in 2.3.x ;-)

The plugin uses a binding value that is no longer available and then there is the forked mode that breaks the plugins setup code.

I better check again before I release 0.10.0 to avoid unnecessary confusion.

beckje01 commented 10 years ago

It works in grails 2.3 for us, if you don't use forked mode.

hauner commented 10 years ago

I mostly fixed this. A release does not make sense at the moment because there a few small issues in grails and functional test (checks wrong fork configuration, functional base url build at the wrong place).

I fixed them in my grails fork but I would like to do a little bit more testing before I open a merge request.

dosaki commented 10 years ago

I'm trying to do the example (so that I can later implement this on my 2.3.x app) I'm using non-forked mode but I still get stuck on appCtx problem :(

Any progress on this issue?

hauner commented 10 years ago

Yes, I have it working on my machine. I have another merge request open to fix an issue in the functional test code in grails-core.

When it gets merged and released (I am hoping for 2.3.8, but can't promise) I can create a grails-cucumber release that will add proper 2.3 support.

Problem with appCtx is, that it is no longer in the binding of grails 2.3. You can probably work around it using Holders.applicationContext or setting appCtx with Holders.applicationContext. That's what the plugins 2.3 release will do to add compatibility with my older examples.

hauner commented 10 years ago

I published a 0.11.0-SNAPSHOT version of the plugin containing the grails 2.3 support.