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

  • SEARCH
  • Home
  • 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 8466977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:30:30+00:00 2026-06-10T15:30:30+00:00

The Symfony 2.0 bundle directory structure, conventionally, has a Tests directory where tests should

  • 0

The Symfony 2.0 bundle directory structure, conventionally, has a Tests directory where tests should be placed.

Acme
    -> SomeBundle
        -> Controller
        -> Entity
        -> Service
        -> ...
        -> Tests
            -> Controller
            -> Entity
            -> Service
            -> ...
    -> OtherBundle
    -> ...

I am aware the tests work even if they are not under the same namespace as the classes they test.

namespace Acme\SomeBundle\Service;

/**
 * Some service.
 *
 * @author varchar
 * @since  August 1, 2012
 */
class SomeService
{
}

For the class above, I (for one) would usually have a test under the following name space (as influenced by the directory structure):

namespace Acme\SomeBundle\Tests\Service;

Now, this works okay.

Incidentally however, I use the Netbeans IDE which cannot find a test class unless it is under the same namespace (this is notable when you want to test only a single file). Well, this could be just a Netbeans standard (or something).

Regardless however, is it appropriate to put tests under the same namespace as the class being tested? Are there any merits in doing so?

Question

1) Is it appropriate to put tests under the same namespace as the class being tested?

2) Are there any merits in doing so?

  • 1 1 Answer
  • 0 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-06-10T15:30:32+00:00Added an answer on June 10, 2026 at 3:30 pm

    Is it appropriate to put tests under the same namespace as the class being tested?

    So far, there have been no issues regarding about this. So this would, perhaps, only be a matter personal preference, for now.

    Are there any merits in doing so?

    It seems there are.

    1) Since the test and the class will be sharing the same namespace, no need for

    use Acme\SomeBundle\Tests\Service
    

    in the test class. In other words, it is slightly more convenient to create a test sharing the same namespace as the class.

    2) If you are using NetBeans then you will be able to run a test on a single class using the IDE.

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

Sidebar

Related Questions

Here is my controller: <?php namespace Home\JoinBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Home\JoinBundle\Entity\User; class DefaultController extends
I understand that a bundle should contain the directory structure and other conventions outlined
Is this possible to change bundle structure in Symfony 2, for example: MyBundle EntityName
i have downloaded a sonata admin bundle, and have placed in /var/www/Symfony/vendor/symfony/src/Symfony/Bundle , and
The Problem: I am working on a WordPress Symfony bundle and creating entities for
ValidateGatherType.php namespace D2E\CoreBundle\Form; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilder; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template; class ValidateGatherType extends
In Symfony 2 I have the following code in my Controller: // prepare to
In the root of every Symfony 2 bundle is a file XXXBundle.php , where
I'm following How to Override any Part of a Bundle page on Symfony 2
What is the best way to access Zend Autoloader inside my Symfony bundle so

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.