Giter VIP home page Giter VIP logo

grails-cucumber's Introduction

Cucumber Grails Plugin

grails-cucumber is a Grails plugin for Cucumber based on Cucumber-JVM. Cucumber-JVM is the JVM implementation of cucumber with support for many JVM languages.

See the wiki for more information, especially the plugin guide or the articles that walk through simple examples.

Quick Usage

The plugin integrates cucumber as a grails test type into the grails test infrastructure. That means you can run the cucumber features with test-app and that the results will be included in the usual grails test reports.

Currently the plugin registers the cucumber test type only to the functional test phase. To run the cucumber features you call grails by one of the following commands:

grails test-app functional:cucumber
grails test-app :cucumber
  • cucumber features and steps are expected in the test/functional folder

  • step implementations look like this:

      import static cucumber.api.groovy.EN.*
    
      Given (~'^I have specified my app by example$') { ->
      	// implement me using groovy and grails code
      }
      
      When (~'^I run the specification without failures$') { ->
      	// implement me using groovy and grails code
      }
      
      Then (~'^I am confident the app does what the customer wanted$') { ->
      	// implement me using groovy and grails code
      }
    
  • failing steps, steps with errors or undefined steps are all reported by grails as FAILED. The normal cucumber output can be found in target/test-reports

  • You can provide feature and scenario filters on the command line. The plugin does currently support cucumbers @tag and dir/file:line filters. See cli options.

Changes

see CHANGES.md

Development

Plugin test code

  • the plugin has a number of unit tests and a single "cli" test. There are also a number of cucumber tests which are not meant to be run directly. They are only used by the "cli" test. You can run the cli test with

grails test-app other:cli

and the unit tests with

grails test-app unit:

The unit tests will also run from an IDE without starting up grails (works for me with IDEA 11.1).

grails-cucumber's People

Contributors

hauner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grails-cucumber's Issues

Why ":resources:1.2.8" is declared in dependencies?

Hey everyone

I'm a bit confused why ":resources:1.2.8" is listed in BuildConfig? I prefer asset-pipline, so my app does not use it explicitly. Adding resources via 'cucumber' causes my app crashing.

How about to clean BuildConfig to utilise only really-used dependencies?

@tag command line

Re-Implemented @tag support.

grails :cucumber @tag

instead of

grails :cucumber ++tags @tag

see also #11

what version of cucumber is implemented in this plugin?

current cucumber-jvm is 4.2.0

I would like to use this plugin, but with the latest version of cucumber to have most of the new features and fixes available.

I ask about updating just the library because I know there is a lot of work updating the whole plugin to Grails 3.x, that is also why I'm testing with Grails 2.5.6.

Also, if I can collaborate updating the jvm dependency, please let me know where can I start. Thanks.

Fatal error running test

(remove this issue, probabbly it will be fixed in 1.0.0, with the grails 2.4 support)

With Grails 2.4.0, in a Ubuntu 13.04 with OpenJDK,

BuildConfig:

test ":cucumber:0.7.0"

I want to run the "NewBook" example, and when I execute

grails test-app functional:cucumber --stacktrace

The response is:

| Running without daemon...
| Error Error loading event script from file [/home/usuario/Documents/blahblahblah/target/work/plugins/cucumber-0.7.0/scripts/_Events.groovy] No such property: classLoader for class: java.lang.Object (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
groovy.lang.MissingPropertyException: No such property: classLoader for class: java.lang.Object
at grails.util.BuildSettings$1.doCall(BuildSettings.groovy:409)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1270)
at _Events.run(_Events.groovy:17)
| Error Error loading event script from file [/home/usuario/Documents/blahblahblah/target/work/plugins/cucumber-0.7.0/scripts/_Events.groovy] No such property: classLoader for class: java.lang.Object

java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object

I'm getting the problem described in #6

I've started with a completely blank project.
Followed the instructions at https://github.com/hauner/grails-cucumber/wiki/Testing-Grails-with-Cucumber-and-Geb to the point where firefox is launching and the test is failing.
Then I went through and updated geb and selenium to the latest versions - everything still worked.
Finally I updated cucumber from 0.2.3 to 0.5.0 at which point I get the NullPointer...

| Error Error executing script TestApp: java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object (Use --stacktrace to see the full trace)

BuildConfig.groovy

def gebVersion = '0.7.0'
def seleniumVersion = '2.21.0'

dependencies {
    test "org.codehaus.geb:geb-junit4:$gebVersion"
    test "org.seleniumhq.selenium:selenium-firefox-driver:$seleniumVersion"
    test "org.seleniumhq.selenium:selenium-support:$seleniumVersion"
}

plugins {
    runtime ":hibernate:$grailsVersion"
    runtime ":jquery:1.7.1"
    runtime ":resources:1.1.6"

    test ":geb:$gebVersion"
test ":cucumber:0.2.3"

    build ":tomcat:$grailsVersion"
}

GebConfig.groovy

import org.openqa.selenium.firefox.FirefoxDriver

driver = {
    new FirefoxDriver()
}

No CucumberConfig.groovy

StackTrace

phobos:cucumber-test steve$ grails test-app functional:cucumber --stacktrace
| Server running. Browse to http://localhost:8080/cucumber-test
| Server stopped
| Tests FAILED  - view reports in target/test-reports
| Error Error executing script TestApp: java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object
at geb.Page.propertyMissing(Page.groovy)
at cucumber.runtime.groovy.GroovyBackend.parse(GroovyBackend.java:96)
at cucumber.runtime.groovy.GroovyBackend.loadGlue(GroovyBackend.java:61)
at cucumber.runtime.Runtime.<init>(Runtime.java:63)
at grails.plugin.cucumber.CucumberTestType.prepareCucumber(CucumberTestType.groovy:90)
at grails.plugin.cucumber.CucumberTestType.doPrepare(CucumberTestType.groovy:56)
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:282)
at _GrailsTest_groovy$_run_closure4.call(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:248)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:195)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:184)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at TestApp$_run_closure1.doCall(TestApp.groovy:82)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at gant.Gant.executeTargets(Gant.groovy:590)
| Error Error executing script TestApp: java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object

No output inside step definitions

Hi,

I have the following step definition:

import groovy.time.TimeCategory;
import cucumber.table.DataTable;
import net.inductiva.collector.ExternalDataSource;

this.metaClass.mixin (cucumber.runtime.groovy.EN)
println("HELLO")
Given(~'^the following external datasources:$') { eds ->
println("HELLO Inside Given")
assert false
}

The second print does not get printed, the steps runs since it fails due to the assert false statement.

moving cucumber out of `test/functional` will not find helper classes

If I configure cucumber to use its own directory via CucumberConfig.groovy to avoid issue with geb, using test/cucumber for cucumber and test/functional for geb, and I have some support classes (not steps or hooks) in its own files and packages, cucumber will not find them below test/cucumber because test/cucumber is not on the class path.

Because cucumber runs inside the functional test phase test/functional will be on the class path and moving the extra code into test/functional will fix it.

Question is: should the plugin add the glue path(s) to the class path?

Before I moved the default folder to test/functional, test/cucumber was added to the class path.

I guess the answer to the question is yes because at first I was confused myself that cucumber couldn't find the classes.... ;-)

Debug step definitions with Eclipse

I'm using Eclipse (SpringSource Tool Suite 2.9.1) and Java 7, however if I define breakpoints inside my step definitions the debugger is not triggered as it should be.

For running the tests I'm using the command grails test-app functional:cucumber and using test ":cucumber:0.2.3" version of the plugin.

improve scenario failure reporting

Reporting step failures as failure of the scenario is heavily confusing in IDEAs test runner. It is not clear anymore if it is scenario or a step. Probably best to not report step failures like that and depend on the scenario output.

Keeping session state between steps

I'm trying to use cucumber to test a shopping basket controller but the session appears to be reset after each step. Each time a product is added to the basket it has disappeared by the next call.

Is there any way I can keep the session live to emulate a browser without having to delve into HTTP?

Thanks,

P.

Grails 2.3 Support

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.

Before per steps file

I have two feature files and two steps groovy files.

Defined the Before method on both steps files, the issue I'm having is the test execution calls both Before methods, before executing steps on each file.

The expected behavior would be, if Before is defined on env.groovy, to run for any steps file, but if the Before is defined on a specific steps file, that Before should run just for those steps.

The issue this generates, for instance, is when a variable should be initialized and has the same name. like this.myvar, on both Before methods, the myvar gets assigned to the value set by the steps file which Before is called last, getting the wrong value on when running the first steps file.

I know this can be easily avoided by making the names of the vars unique between steps files, but it would be better to isolate Before methods when declared on a steps file.

I think the same happens with the After methods.

Calling multiple actions in a scenario = error

When I try to call an action (that has a redirect) multiple times within a scenario (my example is add product A and B to shopping basket) I get the error:

org.codehaus.groovy.grails.web.servlet.mvc.exceptions.CannotRedirectException: Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.

In a normal Integration test I would call reset() to allow this to work. How can I do this using Cucumber?

Thanks again,

Paul.

output from test reports doesn't seem right

Hi I'm testing this plugin on Grails 2.5.6 (the latest 2.x version), and I have this feature file:

Feature: xyz
  some description here

  Scenario: aaa
    Given ...
    When ...
    Then ...

  Scenario: bbb
    Given ...
    When ...
    Then ...

  Scenario: ccc
    Given ...
    When ...
    Then ...

On grails test-app :cucumber I the output for Scenario aaa in the test html report is "Feature xyz ...", then for Scenario bbb the output is "Scenario aaa ....", and for Scenario ccc the output is "Scenario bbb .... Scenario ccc".

It seems the outputs are not mapped to the correspondent Scenario being executed.

ConfigCucumber.groovy is hardcoded

Ability to change name of configuration file is really wanted when grails application is splited into inline plugins (each plugin has CucumberConfig file). In this case CucumberConfig will be compiled multiple times and this leads to compilation error: the same class already compiled or so.

This can be easly fixed by adding abililty to set any name for "CucumberConfig.groovy"

Error running the tests

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
/Users/sergei/.grails/1.3.7/projects/trip-planner/plugins/cucumber-0.1.0/src/groovy/grails/plugin/cucumber/CucumberTestType.groovy: 24: unable to resolve class cucumber.runtime.SnippetPrinter
@ line 24, column 1.
import cucumber.runtime.SnippetPrinter
^

1 error

at org.codehaus.groovy.control.ErrorCollector.failIfErrors(ErrorCollector.java:302)
at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:839)
at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:521)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:470)
at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:453)
at org.codehaus.groovy.tools.FileSystemCompiler.compile(FileSystemCompiler.java:67)
at org.codehaus.groovy.tools.FileSystemCompiler.doCompilation(FileSystemCompiler.java:180)
at org.codehaus.groovy.ant.Groovyc.compile(Groovyc.java:905)
at org.codehaus.groovy.ant.Groovyc.execute(Groovyc.java:607)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at _GrailsCompile_groovy$_run_closure4_closure10.doCall(_GrailsCompile_groovy:117)
at _GrailsCompile_groovy$_run_closure4_closure10.doCall(_GrailsCompile_groovy)
at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:280)
at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy)
at _GrailsCompile_groovy$_run_closure4.doCall(_GrailsCompile_groovy:104)
at _GrailsCompile_groovy$_run_closure3.doCall(_GrailsCompile_groovy:69)
at _Events$_run_closure1.doCall(_Events.groovy:27)
at _Events$_run_closure2.doCall(_Events.groovy:33)
at _Events$_run_closure3.doCall(_Events.groovy:49)
at org.apache.tools.ant.BuildListener$targetStarted.call(Unknown Source)
at TestApp$_run_closure1.doCall(TestApp.groovy:82)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:590)
at gant.Gant.executeTargets(Gant.groovy:589)

Error executing script TestApp: : Compilation Failed

No such property: e for class: _Events

If you create a new grails 2.4.3 app and remove scaffolding, database-migration, and hibernate from the app's BuildConfig.groovy, but add the cucumber plug-in, you'll get the error message Error executing script RunApp: No such property: e for class: _Events when trying to do grails run-app. It appears that in version 1.0.0 of this plugin, it declares dependencies in the POM that end up pulling back in scaffolding, database-migration, hibernate, and the old resources plugin, one of which then causes a problem on an otherwise clean app.

However, if I exclude those when adding the plugin, everything works fine. This is what I have to use in my BuildConfig.groovy to get around this issue:

test (":cucumber:1.0.0") { excludes "database-migration", "hibernate4", "resources", "scaffolding" }

Not All Scenarios Are Written To Test Report

In our Grails app we have two Cucumber features, each with one scenario.

When running these tests (grails test-app) the report generated in target/test-reports/TEST-functional-cucumber-.xml only contain one of the features and scenarios. However all of the tests are running so it only seems to be a problem with the reporting.

I'm using the following versions: -

Grails 2.3.0
Cucumber Plugin 0.9.0

debug mode

Hi Hauner, I trying to run in debug mode (grails 2.3.11 & java 1.6), but I receive the following error in console output:
Invalid memory access of location 0x0 rip=0x7fff91ecd152
ERROR: transport error 202: connect failed: Connection refused
Do you have some idea about this? BR

Grails interactive prompt support

Hi,
When trying to run the functional tests from the grails interactive prompt (Grails 2.2.0), the second time (the first time is ok) the command is run I get the error below.

Trying to stop the server (stop-app) does not make a difference.

It looks like additional cleanup is required between runs...

Stephane.

grails> test-app :cucumber --stacktrace | Running Grails application | Error Server failed to start for port 8080: Address already in use (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.) java.net.BindException: Address already in use at org.springsource.loaded.ri.ReflectiveInterceptor.jlrConstructorNewInstance(ReflectiveInterceptor.java:975) at org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1243) at _GrailsRun_groovy$_run_closure1.doCall(_GrailsRun_groovy:65) (...)

Cannot get ModelAndView from controller

With my standard Grails integration tests I get given view and model objects to interrogate, but with the cucumber plugin this doesn't appear possible.

Have I missed something?

Thanks,

Paul.

Nullpointer exception when running tests using grails-cucumber 0.4.0

Hi Hauner,

Recently I updated the plugin and I started to get this message when running tests. It only happens when there's a geb.Page object created. If I remove the class, everything works fine. I tried to update Geb, Selenium, Cucumber but it didn't worked.

Your plugin is improving really fast, and I'm anxious to use the next version!

Here goes the stacktrace:

| Error Error executing script TestApp: java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object (NOTE: Stack trace has been filtered. Use --verbose to see entire trace.)
java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object
at geb.Page.propertyMissing(Page.groovy)
at cucumber.runtime.groovy.GroovyBackend.parse(GroovyBackend.java:94)
at cucumber.runtime.groovy.GroovyBackend.loadGlue(GroovyBackend.java:58)
at cucumber.runtime.Runtime.(Runtime.java:63)
at grails.plugin.cucumber.CucumberTestType.prepareCucumber(CucumberTestType.groovy:88)
at grails.plugin.cucumber.CucumberTestType.doPrepare(CucumberTestType.groovy:55)
at _GrailsTest_groovy$_run_closure4.doCall(_GrailsTest_groovy:282)
at _GrailsTest_groovy$_run_closure4.call(_GrailsTest_groovy)
at _GrailsTest_groovy$_run_closure2.doCall(_GrailsTest_groovy:248)
at _GrailsTest_groovy$_run_closure1_closure21.doCall(_GrailsTest_groovy:195)
at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:184)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at TestApp$_run_closure1.doCall(TestApp:82)
at org.codehaus.gant.GantMetaClass.invokeMethod(GantMetaClass.java:133)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16_closure18.doCall(GantBinding.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at org.codehaus.gant.GantBinding.withTargetEvent(GantBinding.groovy:90)
at org.codehaus.gant.GantBinding.this$4$withTargetEvent(GantBinding.groovy)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy:185)
at org.codehaus.gant.GantBinding$_initializeGantBinding_closure5_closure16.doCall(GantBinding.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415)
at gant.Gant$_dispatch_closure7.doCall(Gant.groovy)
at java_util_concurrent_Callable$call.call(Unknown Source)
at gant.Gant.withBuildListeners(Gant.groovy:427)
at gant.Gant.this$2$withBuildListeners(Gant.groovy)
at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source)
at gant.Gant.dispatch(Gant.groovy:415)
at gant.Gant.this$2$dispatch(Gant.groovy)
at gant.Gant.invokeMethod(Gant.groovy)
at gant.Gant.executeTargets(Gant.groovy:591)
at gant.Gant.executeTargets(Gant.groovy:590)
| Error Error executing script TestApp: java.lang.NullPointerException: Cannot invoke method propertyMissing() on null object

compiling step files

moved from #15

cressie176:

Hi Martin,

Sorry for the lack of response. This is a pet project and I got side
tracked onto real work for a few days. I got it working now too. I'd
referenced an older version of the Geb plugin, and also not separated out
the steps into a separate cucumber directory.

Now that's working I've hit another snag. It doesn't seem possible to use
the grails-remote-control plugin with the cucumber plugin to setup remote
test data, e.g.

remote {
Book.build()
}

The reason is that the remote plugin requires the remote closure to be
compiled into a class file, but grails isn't creating class files for the
code under test/cucumber. I can workaround by putting the closures below
the test/functional source folder, but it's going to be a bit nasty. Any
thoughts?

Thanks,

Steve

On 2 June 2012 16:25, Martin Hauner <
[email protected]

wrote:

Not 100% sure but I guess it is the CucumberConfig.groovy file. If you
use test/cucumberand test/functional you have to configure this in the
config file because the plugin uses test/functional as default now. I
have updated the cucumber grails geb article.

Another possibility is a missing import in a step file. If you see
GroovyBackend.parse in the callstack, cucumber has a problem parsing a
groovy script file (hooks or steps). Spent already a few hours myself
looking for this erro a couple of times....

Reply to this email directly or view it on GitHub:
#15 (comment)

errorOutstanding compiling grails project with cucumber 0.9.0-SNAPSHOT

Hi Hauner

I got this error compiling grails 2.2.0 project:

*** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ../../../src/share/instrument/JPLISAgent.c line: 844

I'm running:
Ubuntu 13.04
Kernel: 3.8.0-26-generic #38-Ubuntu SMP Mon Jun 17 21:43:33 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

java version "1.7.0_21"
OpenJDK Runtime Environment (IcedTea 2.3.9) (7u21-2.3.9-1ubuntu1)
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode)

Groovy enVironment Manager 1.2.1

Grails 2.2.0

Only one plugin, besides standard artifacts of new project
test ":cucumber:0.9.0-SNAPSHOT"

I downgrade to cucumber.0.8.0 and all run fine.

I guess it can be the steps precompilation.

Thank you.

is the hook "integration" still supported in plugin 1.2 grails 2.3 ?

hello,
the doc says it's "deprecated", do you mean it does not work any more or it's not recommended any more ?
given env.groovy

import static grails.plugin.cucumber.Hooks.hooks
hooks {
    integration ("@integration")
}

and i put the tag @integration above a "scenario"
when the step calls a gorm method
then it crashes with "IllegalStateException: Method on class [my domain class here] was used outside of a Grails application"

Thank you for the precisions.
(i'm interested in having access to gorm and spring (appCtx) to port existing integration tests to cucumber)

False positive results

In some scenarios, it might inform a test has been succeeded when it is not. For instance, the image show the test passed, even though it says System error instead of System output
falsopassed

before/after hook templates for common setup teardown code

I'm thinking about adding some kind of library to the plugin that contains before/after pair hook scripts for some common setup/teardown code.

for example

  • before/after for grails integration test setup/teardown for controllers (i.e. mock request/response etc.)
  • before/after for handling shiro test setup/teardown
  • before/after to rollback the transaction after a scenario (enabled by default..)

Not yet sure how one would use it.

  • by running the pre-defined scripts manually (would be a simple one liner in a glue code script).
  • or by providing a mixin with some setup methods that will take care of running the scripts
  • or simply by providing the code to add to before/after to enable it

Probably we would like to have some of them depend on cucumber tags.

failed testing grails cucumber

Hello,

I download the code at : https://github.com/hauner/grails-cucumber
And when I test this code by executing : grails test-app functional:cucumber
I get this error :
Error Fatal error running tests: ServletContext must not be null

I'm using grails v2.3.7. I really don't understand why this error happens. I have searched on the web differents possibilities but all I found lead to nothing.

Regards

Write features in other languages

I can write steps in any language by modifying the cucumber mixin at the top of the step. However, it is not possible to write features in other languages since the gherkin.lexer used is always considering english features.

Unable to run Cucumber tests with Jetty as a container?

Hi,

I seem to be unable to run cucumber tests with Jetty as a container.
(I am using grails 2.3.3)

In my BuildConfig.groovy:

plugins {
    test ":cucumber:0.10.0"
    //(...)
    build ":jetty:2.0.3"
}

When running grails test-app :cucumber --stacktrace I get:

| Error No default container found. Please install a container plugin such as 'tomcat' first.

java.lang.NullPointerException with 'grails test-app'

Tried the instructions at https://github.com/hauner/grails-cucumber/wiki/Testing-Grails-with-Cucumber-and-Geb

I ran into an issue with running 'grails test-app' to validate the cucumber and geb plugin install

My project can be found here:
https://github.com/balexander123/Books

Here's the output...

Loading Grails 2.2.2
| Configuring classpath.
| Environment set to test.....
| Packaging Grails application.....
| Tests FAILED - view reports in /Users/barryalexander/Documents/workspace-ggts/Books/target/test-reports
| Error java.lang.NullPointerException
| Error at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
| Error at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
| Error at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
| Error at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
...

Transactional Fixtures

Hello Hauner,

Im using grails-cucumber and all was going great, until I had to create a feature in which some scenarios depend from common preconditions (data).

I created a Context to setup the data, but the context is run in every Scenario Execution, without rollback. This made my Scenarios depend on each other and in the order that they were run.

Google told me that Ruby-Cucumber can be configurated with ''Cucumber::Rails::World.use_transactional_fixtures = true".
Another option would be to implement @before and @after hooks, but I couldn't manage to import those annotations (like 'import cucumber.annotation.After')

Is there anything I can do to make my Scenarios independent from each other and still declare a Context?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.