Re: Re: Spindle compatability test suite

"Geoff Longman" <[email protected]> Thu, 11 May 2006 22:51:07 -0400
Newsgroups gmane.comp.ide.eclipse.spindle.devel
Message-ID <[email protected]>
Ok. I see what you have. A fixture is an interface to build a
"project" with context and classpath for testing. Can provide or point
me to (in you repo) an example of a Test?


On 5/10/06, Hugo Palma <[email protected]> wrote:
> Forgot to mention how the tested class implementation would be served to
> the test class.

ok, I'm lost at this point. "tested class implementation" is?


Geoff

> I got this working by declaring a hivemind service for each tested class
> in spindle-tests and then providing the implementation in the IDE
> implementation module. There's also an utility method in
> AbstractSpindleTestCase that gets the tested class implementation.
> I'm not crazy about having to declare every tested class in the hivemind
> descriptor but i couldn't find a better way of doing this.
>
>
> Hugo Palma wrote:
> > I told you i wouldn't let you forget about this :o)
> >
> > I took advantage of a few dead hours in my day job to give this some
> > thought. After some experimenting i came up with some ideas and some
> > code also.
> >
> > There should be a separate module(spindle-tests) with all the
> > framework classes and the tests themselves.
> >
> > The framework consists of one interface, one class and one hivemind
> > descriptor. The interface is IFixture, it provides the signature for
> > all operations that can be executed in a fixture. A fresh instance of
> > the fixture will be provided to each test class at every test run.
> > I've come up with the following code for now, still some operations
> > missing but good for getting the main picture:
> >
> > /**
> >  * A test fixture. Should have an implementation for each IDE.
> >  */
> > public interface IFixture<W, F>
> > {
> >     /**
> >      * Adds a web root.
> >      *
> >      * @param filePath     the absolute path to the web root directory.
> >      * @param relativePath the relative path of the web root. Some
> > IDEs let the user specify a different relative path for each web root,
> > changing the default "/" path.
> >      * @return the added web root.
> >      */
> >     W addWebRoot(String filePath, String relativePath);
> >
> >     /**
> >      * Adds a web root with the default "/" relative path.
> >      *
> >      * @param filePath the absolute path to the web root directory.
> >      * @return the added web root.
> >      */
> >     W addWebRoot(String filePath);
> >
> >     /**
> >      * Adds an empty file to a web root.
> >      *
> >      * @param webRoot the web root to add the file to.
> >      * @param path    the absolute path of the file to be added.
> >      * @return the added file.
> >      */
> >     F addFileToWebRoot(W webRoot, String path);
> >
> >     /**
> >      * Adds a source root.
> >      *
> >      * @param filePath the absolute path to the source root directory.
> >      * @return the added source root.
> >      */
> >     F addSourceRoot(String filePath);
> >
> >     /**
> >      * Adds an empty class to a source root.
> >      *
> >      * @param root        the source root to add the class to.
> >      * @param packageName the class package.
> >      * @param className   the class name.
> >      */
> >     void addClassToSourceRoot(F root, String packageName, String
> > className);
> >
> >     /**
> >      * Adds a .jar file to the classpath.
> >      *
> >      * @param jarFile the .jar file to add to the classpath.
> >      */
> >     void addJarToClasspath(F jarFile);
> >
> >     /**
> >      * Adds a file to a source root.
> >      *
> >      * @param root        the source root to add the file to.
> >      * @param packageName the package to add the file to.
> >      * @param fileName    the absolute path to the file to be added.
> >      */
> >     void addFileToSourceRoot(F root, String packageName, String
> > fileName);
> >
> >     /**
> >      * Tears down the fixture.
> >      */
> >     void tearDown();
> > }
> >
> >
> > The base class for all tests is also provided. I called it
> > AbstractSpindleTestCase. This class provides a getFixture() method to
> > every subclass and is responsible for getting the fresh fixture
> > instance from Hivemind at every test run. Here's the code i came up wit=
h:
> >
> > /**
> >  * Base class for all test classes.
> >  *
> >  * @author Hugo Palma
> >  */
> > public abstract class AbstractSpindleTestCase extends TestCase
> > {
> >     private IFixture _fixture;
> >     private static Registry _registry;
> >
> >     {
> >         _registry =3D RegistryBuilder.constructDefaultRegistry();
> >     }
> >
> >     /**
> >      * {@inheritDoc}
> >      */
> >     protected void setUp() throws Exception
> >     {
> >         super.setUp();
> >
> >         // Allows getting a brand new IFixture instance every time.
> >         _registry.cleanupThread();
> >         _registry.setupThread();
> >
> >         _fixture =3D (IFixture) _registry.getService(IFixture.class );
> >     }
> >
> >     /**
> >      * {@inheritDoc}
> >      */
> >     protected void tearDown() throws Exception
> >     {
> >         super.tearDown();
> >
> >         // Cleanup the fixture.
> >         _fixture.tearDown();
> >         _fixture =3D null;
> >     }
> >
> >     protected IFixture getFixture()
> >     {
> >         return _fixture;
> >     }
> > }
> >
> > The only thing missing is the hivemodule.xml in the spindle-tests modul=
e:
> >
> > <module id=3D" net.sf.spindle.tests" version=3D"1.0.0">
> >     <service-point id=3D"fixture"
> > interface=3D"net.sf.spindle.tests.IFixture"/>
> > </module>
> >
> > So, given this, all the IDE has to do is:
> >
> > - Create an implementation of the IFixture interface.
> > - Provide a hivemodule.xml file in it's spindle-core implementation
> > module with something like:
> >
> >   <module id=3D"org.intellij.tapestry" version=3D" 1.0.0">
> >     <dependency module-id=3D"net.sf.spindle.tests" version=3D"1.0.0"/>
> >
> >     <implementation service-id=3D"net.sf.spindle.tests.fixture">
> >         <invoke-factory model=3D"threaded">
> >             <construct class=3D"org.intellij.tapestry.test.Fixture"/>
> >         </invoke-factory>
> >     </implementation>
> > </module>
> > - Execute the tests. I managed to run the tests from IDEA with no
> > problem. I'm going to see how/if i can run tests from a jar file with
> > Maven2.
> >
> >
> > Thoughts ?
>
>
> -------------------------------------------------------
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job ea=
sier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim=
o
> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=
=3D121642
> _______________________________________________
> Spindle-developer mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/spindle-developer
>


--=20
The Spindle guy. http://spindle.sf.net
Blog:                  http://jroller.com/page/glongman
Other interests:  http://www.squidoo.com/spaceelevator/


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642