You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jorg Heymans <jh...@domek.be> on 2005/09/13 10:01:37 UTC

[m2] mock classes

Hi,

I am trying to model this directory structure inside one of our modules
into a runnable pom

./src
./mocks

The mocks need to be compiled and added as a dependency to the src
classpath.

I know I could make this work by having a separate module for the mocks
and add it as a "provided" dependency, but as we have 55 modules already
this solution is not preferred.


Is there an official m2 way of solving this ?


Thanks
Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] mock classes

Posted by John Fallows <jo...@gmail.com>.
There seems to be a bigger issue here too.

What if I have the following project structure

project/
  api-module/
    src/
      main/
      mock/
      test/
  impl-module/
    src/
      main/
      test/

Now, api-module needs to provide mocks for use by both the api-module
unit tests the impl-module unit tests.

For impl-module unit test code to get the right dependency, the
api-module mocks must be delivered as a JAR.  This must be separate
from the the main api-module JAR.

So, why not just put the mocks in src/mock (alongside src/test) and
make a mocks JAR as the secondary api-module deliverable?

Well, that would need to JAR up the compiled mock classes which will
be in api-module/target/test-classes.  However, these test classes
also include the compiled src/test/java classes, as well as test
resources.

Note: it is also not possible to split this out as a separate module,
because there would be a cyclic dependency between api-module and
"api-mock-module".

Is there a way to deliver an api-module mock JAR that only contains
classes for mocks, and can be used by both the api-module unit tests
and the impl-module unit tests?

Kind Regards,
John Fallows.

On 9/13/05, Jorg Heymans <jh...@domek.be> wrote:
> 
> Trygve Laugstøl wrote:
> 
> > Just treat the mocks as unit test source code and use
> >
> > <project>
> >   ..
> >   <build>
> >     ..
> >     <testSourceDirectory>mocks</testSourceDirectory>
> >     ..
> >   </build>
> > </project>
> >
> 
> Just tried this, doesn't seem to work.
> 
> 
> Jorg
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] mock classes

Posted by Jorg Heymans <jh...@domek.be>.
Trygve Laugstøl wrote:

> Just treat the mocks as unit test source code and use 
> 
> <project>
>   ..
>   <build>
>     ..
>     <testSourceDirectory>mocks</testSourceDirectory>
>     ..
>   </build>
> </project>
> 

Just tried this, doesn't seem to work.


Jorg


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: [m2] mock classes

Posted by Trygve Laugstøl <tr...@codehaus.org>.
On Tue, 2005-09-13 at 10:01 +0200, Jorg Heymans wrote:
> Hi,
> 
> I am trying to model this directory structure inside one of our modules
> into a runnable pom
> 
> ./src
> ./mocks

Just treat the mocks as unit test source code and use 

<project>
  ..
  <build>
    ..
    <testSourceDirectory>mocks</testSourceDirectory>
    ..
  </build>
</project>

See [1] for the reference.

[1]: http://maven.apache.org/maven2/maven-model/maven.html

--
Trygve


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org