You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Jan Torben Heuer <jt...@mail2003.dnsalias.org> on 2007/11/20 14:02:49 UTC
Maven, junit and Mock Classes
I have have (again) a design question, where to place "Mock" Classes for
junit.
Example:
project-core (depends project-dao)
public TestSomeCoreFunctions {
DAO dao = new MockDAO();
...
}
project-dao
public interface dao {
public AccessObject1 do();
}
public interface AccessObject1 {
}
project-another module (depends project-core)
public TestSomeThing {
DAO dao = new MockDAO();
AccessObject1 ao = new MockAccessObject();
...
}
So where can I put both Mock Objects?
Obviously not in the dao, because testclasses are not dependencies.
So I would end up with a project for each or all MockObjects.
project-dao-mock (depends project-dao)
public class MockAccessObject implements AccessObject1..
This means in turn, that I COULD NOT use the mock objects in the project-dao
(circular dependencies), but I NEED them for my junit tests...
So what? I'm confused ;-)
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
RE: Re: Maven, junit and Mock Classes
Posted by "Siegmann Daniel, NY" <Da...@fja-us.com>.
You could use the test jar mojo:
http://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html
--
Daniel Siegmann
FJA-US, Inc.
512 Seventh Ave., New York, NY 10018
(212) 840-2618 ext. 139
-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of Jan Torben Heuer
Sent: Wednesday, November 21, 2007 11:06 AM
To: users@maven.apache.org
Subject: Re: Maven, junit and Mock Classes
Antonio Petrelli wrote:
> Mock classes can stay in the src/test/java directory. What's the
problem?
That directory is not available as dependency.
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Maven, junit and Mock Classes
Posted by Jan Torben Heuer <jt...@mail2003.dnsalias.org>.
Antonio Petrelli wrote:
> Mock classes can stay in the src/test/java directory. What's the problem?
That directory is not available as dependency.
Jan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org
Re: Maven, junit and Mock Classes
Posted by Antonio Petrelli <an...@gmail.com>.
2007/11/20, Jan Torben Heuer <jt...@mail2003.dnsalias.org>:
>
> I have have (again) a design question, where to place "Mock" Classes for
> junit.
Mock classes can stay in the src/test/java directory. What's the problem?
Antonio
Re: Maven, junit and Mock Classes
Posted by Francois Fernandes <f....@gmx.net>.
Guten Tag Jan Torben Heuer,
Hi Jan,
> So where can I put both Mock Objects?
> Obviously not in the dao, because testclasses are not dependencies.
> So I would end up with a project for each or all MockObjects.
You may specify the test-classes as a dependency using the test-jar
mojo of the jar plugin:
http://maven.apache.org/plugins/maven-jar-plugin/test-jar-mojo.html
Using this, you'll have jars containing the test-classes which will be
available using the "tests" classifier
Using that technique, it is possible to place your mock-objects inside
project-dao (or project-core, if the class-level dependencies allow
you to do so).
hope that helps.
Francois
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org