Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 660305
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:08:28+00:00 2026-05-13T23:08:28+00:00

I am learning the concepts of Test-Driven Development through reading the Craftsman articles (click

  • 0

I am learning the concepts of Test-Driven Development through reading the Craftsman articles (click Craftsman under By Topic) recommended in an answer to my previous question, “Sample project for learning JUnit and proper software engineering”. I love it so far!

But now I want to sit down and try it myself. I have a question that I hope will need only a simple answer.

How do you organize your JUnit test classes and your actual code? I’m talking mainly about the package structure, but any other concepts of note would be helpful too.

Do you put test classes in org.myname.project.test.* and normal code in org.myname.project.*? Do you put the test classes right alongside the normal classes? Do you prefer to prefix the class names with Test rather than suffix them?

I know this seems like the kind of thing I shouldn’t worry about so soon, but I am a very organization-centric person. I’m almost the kind of person that spends more time figuring out methods to keep track of what to get done, rather than actually getting things done.

And I have a project that is currently neatly divided up into packages, but the project became a mess. Instead of trying to refactor everything and write tests, I want to start fresh, tests first and all. But first I need to know where my tests go.


edit: I totally forgot about Maven, but it seems a majority of you are using it! In the past I had a specific use case where Maven completely broke down on me but Ant gave me the flexibility I needed, so I ended up attached to Ant, but I’m thinking maybe I was just taking the wrong approach. I think I’ll give Maven another try because it sounds like it will go well with test-driven development.

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:08:29+00:00Added an answer on May 13, 2026 at 11:08 pm

    I prefer putting the test classes into the same package as the project classes they test, but in a different physical directory, like:

    myproject/src/com/foo/Bar.java
    myproject/test/com/foo/BarTest.java
    

    In a Maven project it would look like this:

    myproject/src/main/java/com/foo/Bar.java
    myproject/src/test/java/com/foo/BarTest.java
    

    The main point in this is that my test classes can access (and test!) package-scope classes and members.

    As the above example shows, my test classes have the name of the tested class plus Test as a suffix. This helps finding them quickly – it’s not very funny to try searching among a couple of hundred test classes, each of whose name starts with Test…

    Update inspired by @Ricket’s comment: this way test classes (typically) show up right after their tested buddy in a project-wise alphabetic listing of class names. (Funny that I am benefiting from this day by day, without having consciously realized how…)

    Update2: A lot of developers (including myself) like Maven, but there seems to be at least as many who don’t. IMHO it is very useful for “mainstream” Java projects (I would put about 90% of projects into this category… but the other 10% is still a sizeable minority). It is easy to use if one can accept the Maven conventions; however if not, it makes life a miserable struggle. Maven seems to be difficult to comprehend for many people socialized on Ant, as it apparently requires a very different way of thinking. (Myself, having never used Ant, can’t compare the two.) One thing is for sure: it makes unit (and integration) testing a natural, first-class step in the process, which helps developers adopt this essential practice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning concepts related to .NET framework. I am confused at one point.
I'm learning the difference between these to concepts. I want to build a public
I'm learning Silverlight and am trying to ingest some new concepts. Just so I
When learning a langugage, I routinely find myself prototyping new concepts outside of the
I'm learning as I go, so I'm not familiar with all of the concepts
Yo community! might need some insights here.. :) I'm learning some more advance js-concepts.
I'm currently in the beginning of learning WCF, as some of the concepts and
I'm still learning Sharepoint and all of its various concepts, so apologies in advance
I'm a .NET developer learning Java EE. These two concepts seem to serve the
Well,I am learning the web development and currently working on PHP and mySQL ,I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.