Hi Adam,

On Jul 22, 2008, at 4:46 AM, Adam Murdoch wrote:



Hans Dockter wrote:
Hi Adam,

On Jul 17, 2008, at 12:48 AM, Adam Murdoch wrote:


- How do you decide what counts as the 'core', and therefore needs to be implemented in java, and what does not count as 'core', and therefore can be (must be?) implemented in groovy.

The core is everything except the DSL layer. As we are in the midst of a refactoring from Groovy to Java this layer isn't yet architecturally as separated as it should be. More or less everything except the DefaultProject, DefaultTask and the org.gradle.groovy package should be in Java.

How about the unit tests for the core? I notice that a lot of the core unit tests are implemented in groovy. Is the plan to keep these, or port them to java? how about new tests? Should they be implemented in java? groovy? don't care?

Personally, I like the idea that we can implement the unit tests using groovy to take advantage of the nice scripting stuff it provides.

I don't feel strong about this. There are two issues I have with Groovy unit tests.

- Performance: We have an abstract test case which is extended by all of our task tests. I have refactored this test from Groovy to Java last week and the execution time of our complete test suite (900 tests) went down from 30 seconds to 15 seconds on my machine.

- Mocking: The Groovy mocking framework does not work if the class under test is written in Java. They want to change this, but that is the way it is right now. So for all future unit tests written in Groovy we should use JMock. There is a JUnit4GroovyMockery class in the test source which I have copied from the Groovy Wiki regarding testing. You might search usages of this class on how to use it. You can't use JMock the Java way in Groovy code. The JUnit4GroovyMockery class is fine for normal use cases. But I could not make it work for more complex argument matching like:

context.checking {
        one(myMock).someMethod(with(any(String.class))
}

I have posted this to the Groovy mailing list and they might come up with a solution.

I see also the benefits of using Groovy for unit tests. We therefore might leave it up to a developer to decide if we are able to solve the JMock issue.

- Hans

--
Hans Dockter
Gradle Project lead
http://www.gradle.org





---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email


Reply via email to