Note that there are some explanatory texts on larger screens.

plurals
  1. POGrails 2.0.3 Integration test failing for strange reason(save() on domain model not available for second call to setup method)
    primarykey
    data
    text
    <p>I've recently begun playing around with Grails 2.0 in earnest but I've hit a roadblock that's not making much sense to me. I've written a integration test that makes use of the @TestFor annotation against a controller, but I'm getting very strange errors out of it. Below is the test, stripped down to the minimum case that duplicates this issue:</p> <pre><code>import org.junit.* import grails.test.mixin.TestFor @TestFor(OrderController) class OrderControllerIntegrationTests { public EndUser user @Before public void initialize() { user = new EndUser(username: UUID.randomUUID().toString(), password: "secret"); user.save() } @Test public void get() { assert true } @Test public void create() { assert true } } </code></pre> <p>In summary, the output I'm getting is that the save() method, in my test setup no longer exists for the second test in this class. Which seems...pretty weird.</p> <p>Here's the full output from grails test-app exampleapp.OrderControllerIntegrationTests:</p> <pre><code>Testsuite: exampleapp.OrderControllerIntegrationTests Tests run: 2, Failures: 0, Errors: 1, Time elapsed: 0.769 sec ------------- Standard Output --------------- --Output from get-- 2012-05-15 22:35:03,491 [main] DEBUG transaction.JDBCTransaction - begin 2012-05-15 22:35:03,493 [main] DEBUG transaction.JDBCTransaction - current autocommit status: true 2012-05-15 22:35:03,493 [main] DEBUG transaction.JDBCTransaction - disabling autocommit 2012-05-15 22:35:03,689 [main] DEBUG hibernate.SQL - insert into widget_user (id, version, password, username, class) values (null, ?, ?, ?, 'exampleapp.EndUser') 2012-05-15 22:35:03,970 [main] DEBUG transaction.JDBCTransaction - rollback 2012-05-15 22:35:03,970 [main] DEBUG transaction.JDBCTransaction - re-enabling autocommit 2012-05-15 22:35:03,970 [main] DEBUG transaction.JDBCTransaction - rolled back JDBC Connection --Output from create-- 2012-05-15 22:35:03,979 [main] DEBUG transaction.JDBCTransaction - begin 2012-05-15 22:35:03,979 [main] DEBUG transaction.JDBCTransaction - current autocommit status: true 2012-05-15 22:35:03,979 [main] DEBUG transaction.JDBCTransaction - disabling autocommit 2012-05-15 22:35:04,207 [main] DEBUG transaction.JDBCTransaction - rollback 2012-05-15 22:35:04,207 [main] DEBUG transaction.JDBCTransaction - re-enabling autocommit 2012-05-15 22:35:04,207 [main] DEBUG transaction.JDBCTransaction - rolled back JDBC Connection ------------- ---------------- --------------- ------------- Standard Error ----------------- --Output from get-- --Output from create-- ------------- ---------------- --------------- Testcase: get took 0.51 sec Testcase: create took 0.251 sec Caused an ERROR No signature of method: exampleapp.EndUser.save() is applicable for argument types: () values: [] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) groovy.lang.MissingMethodException: No signature of method: exampleapp.EndUser.save() is applicable for argument types: () values: [] Possible solutions: save(), save(), save(boolean), save(java.util.Map), save(boolean), save(java.util.Map) at exampleapp.OrderControllerIntegrationTests.initialize(OrderControllerIntegrationTests.groovy:17) </code></pre> <p>Does anyone have any ideas? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload