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 8772079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:57:08+00:00 2026-06-13T17:57:08+00:00

Using phpunit and I am having some trouble with include paths, not for phpunit

  • 0

Using phpunit and I am having some trouble with include paths, not for phpunit itself, but for my code and tests directory.

I have the following code structure:

Application
  -StringCalculator.php

tests
  -StringCalculatorTest.php

Inside my StringCalculatorTest.php i have a require statement:

require_once('../StringCalculator.php');

Running phpunit StringCalculatorTest.php from inside the tests folder works perfectly.

However, when i then introduce a phpunit.xml configuration file in the root directory i.e.

Application
  -StringCalculator.php

tests
  -StringCalculatorTest.php

phpunit.xml

the include path is screwed. I have to replace the require_once to

require_once('StringCalculator.php');

What is the correct way to set include paths between the application and the test directory?

  • 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-13T17:57:10+00:00Added an answer on June 13, 2026 at 5:57 pm

    The best place to set your PHP include path is in your bootstrap file. Usually, your phpunit.xml file will include a bootstrap attribute:

    <phpunit backupGlobals="true"
         backupStaticAttributes="false"
         bootstrap="bootstrap.php"
         cacheTokens="true"
         colors="true"
         ... and so on ...
    </phpunit>
    

    Then in your bootstrap file you can set include paths, include important files, etc..

    set_include_path(get_include_path() . PATH_SEPARATOR . '../my/sources');
    

    The config file is covered in Appendix C of the PHPunit docs.

    EDIT: Link updated

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

Sidebar

Related Questions

I am currently performing unit tests on my code (using PHPUnit and Jenkins) but
I'm using PHPUnit 3.4.9, but I'm having some problems with the @depends annotation. It
I have been using PHPUnit for a while now, but suddenly hit a big
PHPUnit seems to execute properly (appropriate tests are executed & pass), but during code
I'm using phpunit framework and I have a code like this: public function A()
I have recently become involved with some TDD using PHPUnit. I have to test
I'm writing unit tests for a project (written in PHP, using PHPUnit) that have
currently I'm using phpunit to write tests for some functions that access a mysql-database.
I am using PHPUnit to test my PHP source code, but I need a
i am using selenium with phpunit to test some of my web stuff but

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.