keeganwitt / gmock

Automatically exported from code.google.com/p/gmock
6 stars 2 forks source link

AST transformation @WithGMock #71

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example:

@WithGMock
class SomeTest extends TestCase { // not extending GMockTestCase
  void testSomething() {
    def mock = mock()
    mock.fun()
    play {
      mock.fun()
    }
  }
}

The code above will be transformed to:

class SomeTest extends TestCase {
  private $gMockController = new org.gmock.GMockController()
  private mock(Object... args) {
    $gMockController.mock(args)
  }
  ...
  private match(Closure closure) {
    org.gmock.GMock.match(closure)
  }
  ...
  void testSomething() {
    def mock = mock()
    mock.fun()
    play {
      mock.fun()
    }
  }
}

Original issue reported on code.google.com by JohnnyJianHY on 6 Mar 2009 at 12:12

GoogleCodeExporter commented 9 years ago

Original comment by julien.g...@gmail.com on 19 Mar 2009 at 7:05

GoogleCodeExporter commented 9 years ago

Original comment by julien.g...@gmail.com on 23 Mar 2009 at 7:20

GoogleCodeExporter commented 9 years ago
I think we can support TestNG with this feature, so I suggest to provide some 
tests
(or a sample) against TestNG with this AST transformation.

Original comment by JohnnyJianHY on 27 Mar 2009 at 5:05

GoogleCodeExporter commented 9 years ago
We've got AST Transformations now! I was quite please to learn about it. Still 
a simple println statement can be 
quite verbose in AST. 

I am not sure how we can easily provide a TestNG sample but if you can think of 
a simple way please give it a 
try.

Original comment by julien.g...@gmail.com on 29 Mar 2009 at 12:29

GoogleCodeExporter commented 9 years ago
Well done!

I agree that AST is verbose, and I remember that the Groovy dev team mentioned 
in the
mailing list that an AST builder will be introduced, which will help a lot.

Original comment by JohnnyJianHY on 29 Mar 2009 at 1:04