You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{code}
| Running 1 unit tests...
| Running 1 unit tests... 1 of 1
| Failure: test something(new_app.FooServiceSpec)
| java.lang.NullPointerException
at new_app.FooServiceSpec.test something(FooServiceSpec.groovy:19)
| Completed 1 unit test, 1 failed in 0m 2s
{code}
If I now go to %app_home%/grails-app/services/new_app/FooService.groovy and remove the @transactional annotation and run
{code}
grails test-app
{code}
I get the following output
{code}
| Running 1 unit tests...
| Running 1 unit tests... 1 of 1
| Failure: test something(new_app.FooServiceSpec)
| Condition not satisfied:
service.serviceMethod()
| |
| null
new_app.FooService@4d905f1f
at new_app.FooServiceSpec.test something(FooServiceSpec.groovy:19)
| Completed 1 unit test, 1 failed in 0m 2s
{code}
and everything works as expected.
Workaround:
If I add the line
{code}
static transactional = true
{code}
to the service instead of the annotation the test still work and I still have the desired behaviour of my service
The text was updated successfully, but these errors were encountered:
We we're seeing a similar issue in Jesque jobs where we had to add @transactional after upgrading to Hibernate 4 due to the lack of an open Session, and prepending...
@TestMixin(DomainClassUnitTestMixin)
to the class and then adding the TransactionManager manually a la...
Original Reporter: spade
Environment: Not Specified
Version: 2.3
Migrated From: http://jira.grails.org/browse/GRAILS-10538
To reproduce run
{code}
grails create-app new_app
grails create-service Foo
{code}
open %app_home%/test/unit/new_app/FooServiceSpec.groovy and edit the generated test to
{code}
void "test something"() {
expect: service.serviceMethod()
}
{code}
If I now run
{code}
grails test-app
{code}
I get the following output
{code}
| Running 1 unit tests...
| Running 1 unit tests... 1 of 1
| Failure: test something(new_app.FooServiceSpec)
| java.lang.NullPointerException
at new_app.FooServiceSpec.test something(FooServiceSpec.groovy:19)
| Completed 1 unit test, 1 failed in 0m 2s
{code}
If I now go to %app_home%/grails-app/services/new_app/FooService.groovy and remove the @transactional annotation and run
{code}
grails test-app
{code}
I get the following output
{code}
| Running 1 unit tests...
| Running 1 unit tests... 1 of 1
| Failure: test something(new_app.FooServiceSpec)
| Condition not satisfied:
service.serviceMethod()
| |
| null
new_app.FooService@4d905f1f
at new_app.FooServiceSpec.test something(FooServiceSpec.groovy:19)
| Completed 1 unit test, 1 failed in 0m 2s
{code}
and everything works as expected.
Workaround:
If I add the line
{code}
static transactional = true
{code}
to the service instead of the annotation the test still work and I still have the desired behaviour of my service
The text was updated successfully, but these errors were encountered: