1

Currently I have a setup running Netbeans, the PHPUnit Framework and SpiraTeam.

I am trying to configure my Netbeans to properly read the xml config for Listeners.

Currently is doesn't seem to be adding the listener at all.

I know it's reading the xml file because when I do not set a TestSuite this file will control what tests are run.

My current phpunit.xml:

<listeners>
   <!-- Not loading this? -->
  <listener class="SpiraListener_Listener" file="PHPUnit/Util/SpiraListener/Listener.php">

   <!-- HOW CAN THIS WORK??? -->
  <int>3</int>

  </listener>
</listeners>

<testsuites>
  <testsuite name="TestSuite">
    <file>./TestSuite.php</file>
  </testsuite>
  <testsuite name="SeleniumTestSuite">
    <file>./selenium_ide_suites/TestSuite.php</file>
  </testsuite>
</testsuites>

<filter>
    <whitelist>
        <directory suffix=".php">../models/</directory>
        <directory suffix=".php">../system/</directory>
        <directory suffix=".php">../controllers/</directory>
        <exclude>
            <directory>../controllers/app_addons/</directory>
            <directory>../controllers/utilities/</directory>
        </exclude>
    </whitelist>
</filter>

And the tests will run as expected but no listener was added. (no error given either)

So I'm really confused as to where to look next!

In addition to that How can you pass params to the class?

http://www.phpunit.de/manual/current/en/appendixes.configuration.html

Says you can add more data in the Listener element of the xml BUT the class is just implemented how is this used / working?

Thanks for any help! --Ron

5
  • 1
    Are you sure that the listener's file is on the include path when PHPUnit starts up -- before bootstrap.php is executed? Commented May 20, 2011 at 7:41
  • yes i added the Listener to my Pear -> PHPUnit -> Utils dir Commented May 22, 2011 at 3:42
  • What exactly happens? Do you get a class not found error? Or does your listener not get the parameters you expect? Please be as detailed as possible and include at least the constructor of your listener. Add debugging output to verify that the file containing the listener is loaded, the constructor gets called, etc. Commented May 22, 2011 at 7:18
  • To be clear saying only "It doesn't work" makes it very hard to guess what's going wrong. Commented May 22, 2011 at 7:19
  • Very true and due to my frustration with the class not calling the __construct I did a pear upgrade-all. The new version of the PHPUnit 3.5+ the __construct is getting called as expected when using the xml configuration. Commented May 24, 2011 at 0:12

1 Answer 1

1

Seems like the syntax of your listener is a little off.

Try:

<listeners>
  <listener class="SpiraListener_Listener" file="PHPUnit/Util/SpiraListener/Listener.php">
    <arguments>
      <integer>3</integer>
    </arguments>
  </listener>
</listeners>
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the input Chris but the issue is not how do you pass in the params to the Listener, but "How do you write the class to use the params when the class is called?"
Just to note I had to rewrite the SpiraListener class as well to take these args as well. I do believe they have updated their class that you can download.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.