Unitils

Invalid syntax. assertMock.list() must be followed by a method invocation on the returned proxy. E.g. assertMock.list().myMethod()

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 3.0
  • Fix Version/s: 3.1
  • Component/s: mock
  • Description:
    list() is my observed method, but unitils dont see that if after this I check something else:

    sampleService.assertInvoked().list(100);
    sampleService.assertInvoked().isValid("XXXX".getBytes());

    sample project attached
  • Environment:
    jdk1.6
  1. unitils-issue.tar.gz
    (2 kB)
    Mariusz Smyku?a
    06/Nov/09 7:35 AM

Activity

Hide
Mariusz Smyku?a added a comment - 06/Nov/09 7:35 AM
Sample project illustrating problem with observated method
Show
Mariusz Smyku?a added a comment - 06/Nov/09 7:35 AM Sample project illustrating problem with observated method
Hide
Tim Ducheyne added a comment - 08/Nov/09 11:46 AM
There was a problem with the chaining mechanism
The problem occurs when an assert is performed on a method has a return value:

For example:
public List<String> list(int value);

sampleService.assertInvoked().list(100);
sampleService.assertInvoked().list(100);

the second assertion will give the syntax error.
The reason for this is that unitils automatically creates a mock list instance and replaces the assertion with:

sampleService.assertInvoked().list(100).assertInvoked();

This makes it possible to do something like (i.e. method chaining):

sampleService.assertInvoked().list(100).iterator();
 

I've fixed the issue so that this no longer causes a syntax error.
 

Thanks for the report, I'll release a new version with the fix as soon as possible.

Grtz,
Tim
Show
Tim Ducheyne added a comment - 08/Nov/09 11:46 AM There was a problem with the chaining mechanism The problem occurs when an assert is performed on a method has a return value: For example: public List<String> list(int value); sampleService.assertInvoked().list(100); sampleService.assertInvoked().list(100); the second assertion will give the syntax error. The reason for this is that unitils automatically creates a mock list instance and replaces the assertion with: sampleService.assertInvoked().list(100).assertInvoked(); This makes it possible to do something like (i.e. method chaining): sampleService.assertInvoked().list(100).iterator();   I've fixed the issue so that this no longer causes a syntax error.   Thanks for the report, I'll release a new version with the fix as soon as possible. Grtz, Tim
Hide
Mariusz Smyku?a added a comment - 12/Nov/09 9:42 AM
I think better is to close bug when new version is released. Now new users can be confused when are searching for open and new bugs...


As a workaround we can ommit this bug actually with resetBehavior();

Example:

sampleService.assertInvoked().list(100);
sampleService.resetBehavior();
sampleService.assertInvoked().list(100);
Show
Mariusz Smyku?a added a comment - 12/Nov/09 9:42 AM I think better is to close bug when new version is released. Now new users can be confused when are searching for open and new bugs... As a workaround we can ommit this bug actually with resetBehavior(); Example: sampleService.assertInvoked().list(100); sampleService.resetBehavior(); sampleService.assertInvoked().list(100);

People

Dates

  • Created:
    06/Nov/09 7:32 AM
    Updated:
    12/Nov/09 9:42 AM
    Resolved:
    08/Nov/09 11:46 AM