Skip to content

Validation within unit test does not work in Grails 3.2 (3.2.1) #10242

@saw303

Description

@saw303

nullable: true does not work within unit tests. The following test describes the problem.

// when @TestFor is removed test fails
//@TestFor(IndividualPerson)
class IndividualPersonSpec extends HibernateSpec {

    @Override
    List<Class> getDomainClasses() {
        [Address, IndividualPerson, Season, User, InvoiceAddress]
    }

    void "Validation fails"() {
        given:
        def member = new IndividualPerson(firstname: 'helo', name: 'wangler', memberSince: '2014', active: Boolean.TRUE)

        when:
        def valid = member.validate()

        and:
        member.save()

        then: 'validation fails'
        valid

        and: 'and of course member is null'
        member.id
    }
}

Steps to Reproduce

  1. Checkout Grails 3.2.1 app
  2. Run test

Expected Behaviour

Validation should work as in production mode.

Actual Behaviour

Validation nullable: true is not respected

Environment Information

  • Operating System: macOS Sierra
  • Grails Version: 3.2.1
  • JDK Version: 1.8

Example Application

  • see above

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions