1

I have a enum

public enum Foo {
    FOO1(true)
    FOO2(false)
    FOO3(true)

    boolean respectACondition

    Foo(boolean isRespecting) {
        respectAContidion = isRespecting
    }

    boolean isRespecting() {
        this.respectACondition
    }
}

And a test class

 class FooTests {

      @Test
      void test() {
          assert  Foo.FOO1.isRespecting()
          assert !Foo.FOO2.isRespecting()
          assert  Foo.FOO3.isRespecting()
      }
 }

But I got this error:

org.codehaus.groovy.grails.exceptions.GrailsConfigurationException: Cannot add Domain class [class Foo]. It is not a Domain!

It seem that grails run a automatic background GrailsUnitTestMixin on the Foo class by deducting it by the class name. If I renamed it, it works (but it's too simple, I wanna know what's the problem) What do I do wrong? Do I need to put my enum outside of the domain directory?

Thermech
  • 4,371
  • 2
  • 39
  • 60
  • 2
    An enum is not a domain. So it shouldn't be in the domain folder. I put all my enums in the src folder under the appropriate language (usually groovy). – Gregg Jun 07 '13 at 00:55

1 Answers1

2

I moved my enum in src\groovy folder and it fix the problem.

Thermech
  • 4,371
  • 2
  • 39
  • 60