users@codemodel.java.net

Re: New developer. Some thoughts on test suite.

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 20 Nov 2006 11:17:26 -0800

Aleksei Valikov wrote:
> Hi folks.
>
> I have joined the codemodel project since I think the tool is simply
> genial. I'll try to take care of the issues that I file myself. I've
> filed a couple of things about JAnnotationUse and JAnnotationArrayMember.

Welcome!

> Another thing I'd like to discuss is testing. Currently there's a couple
> of test classes with main methods there, but they don't perform checks.
>
> What I suggest is testing approach where generated code will be acually
> checked against some target files. This is how it works:
>
> 1. Code model tests extends some base AbstractCodeModelTest which
> prepares and instantiates a code model instance.
>
> 2. During the test, some code is generated into say
>
> target/generated-test-sources/mytTestPackage.myTestClass/src
>
> and
>
> target/generated-test-sources/mytTestPackage.myTestClass/resources
>
> These target directories are set up by te abstract base test.
>
> 3. After code generation is done, all the generated files are compared
> with files from
>
> src/test/generated-test-sources/mytTestPackage.myTestClass/src
> src/test/generated-test-sources/mytTestPackage.myTestClass/resources
>
> What do you guys think?

Sounds good to me.

It would be nice if the comparison would be somewhat smart, so that it
won't flag false positives on "pointless" changes, like the order of
import, indentation, etc, but I guess doing something like that would be
difficult.

-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com