Grails
  1. Grails
  2. GRAILS-9023

@TestFor doesn't work when test class doesn't end with Tests

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.3
    • Fix Version/s: 2.1.4, 2.2.1, 2.3-M1
    • Component/s: Testing
    • Labels:
      None
    • Testcase included:
      yes

      Description

      The following piece of code fails:

      @TestFor(ActivationController)
      class MyControllerTest {
          void testSomething() {
              assert controller
          }
      }
      

      With the following error message:

      groovy.lang.MissingPropertyException: No such property: controller for class: MyControllerTest
      

      This is caused by the name of the test: when I rename it to MyControllerTest*s*, it works. Would be nice if it would work for both cases.

        Activity

        Hide
        Ted Naleid added a comment -

        This bit me too. I was calling params first on some tests so was seeing a similar error message of `No such property: params...` but it was the same cause. My test name omitted the trails "s".

        Show
        Ted Naleid added a comment - This bit me too. I was calling params first on some tests so was seeing a similar error message of `No such property: params...` but it was the same cause. My test name omitted the trails "s".
        Hide
        Rafael Chaves added a comment -

        This may look like a trivial issue (because I assume it is easy to fix) but it is pretty nasty. I was lucky to find this issue, the failure mode is puzzling.

        I couldn't find anywhere in the Grails documentation a convention rule for naming test classes. I believe a reasonable assumption is that if you place a class under test/unit or test/integration and extend the proper base class or use a @TestFor annotation, any naming should work.

        Show
        Rafael Chaves added a comment - This may look like a trivial issue (because I assume it is easy to fix) but it is pretty nasty. I was lucky to find this issue, the failure mode is puzzling. I couldn't find anywhere in the Grails documentation a convention rule for naming test classes. I believe a reasonable assumption is that if you place a class under test/unit or test/integration and extend the proper base class or use a @TestFor annotation, any naming should work.

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            Erik Pragt
          • Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development