Where to keep test-supplementary classes?
I'm trying to create this directory structure in Maven Java project:
pom.xml
/src
/main
/java
/com
/XXX
Foo.java
Bar.java
/test
/java
/com
/XXX
FooTest.java
BarTest.java
/spikes <---- I'm not sure about the right English word for them
/com
/XXX
MockedHttpConnection.java
Thus,开发者_开发知识库 in two tests FooTest
and BarTest
I can use the same MockedHttpConnection
, which is perfectly decoupled from them both, staying at the same time in the same package with them. What do you think about this approach? I have a feeling that I'm reinventing a wheel, but I can't find any patterns for this mechanism in Java.
If MockedHttpConnection is your own class I'd suggest you to store it under /test/java/com/testutil
.
If it is third party class, just add jar to your classpath
.
I'd sugget having it in your test package because in the end is testing code.
It's the same as the application. You don't just store your application main class under main. You store it and everything it needs to be executed.
精彩评论