Closed daniela-waranie closed 14 years ago
To make it clear: i can not notice the skipped test in the "Test Results" window of netbeans. In the command line output (not the XML) i can see the skipped test. Commandline output and xml should be semantic equal.
The actual issue is that PHPUnit_Util_Log_JUnit
ignores PHPUnit_Framework_Warning
errors (which is what you get when you specify a @dataProvider
that doesn't exist).
For what it's worth, I fixed this in a local branch but it didn't solve the problem with netbeans.
Currently the JUnit result printer will not print the same count for test cases and failures or the same errors as the other result printers if any warnings are encountered. Even after fixing the JUnit result printer to match the other result printers, neatbeans still prints misleading results.
It seems that neatbeans is only looking at the individual test cases for failures and not the overall test suite results. This is problematic as some warnings refer to errors that occur outside of a specific test case. It's possible to create a specific class of warning that relates to warnings that are encountered while trying to execute a specific test case and then handle those in a way that netbeans can recognize but that doesn't solve the overall problem. I think this is something that will have to be fixed in neatbeans as well.
If your data provider returns an empty array your xml looks like this: `<?xml version="1.0" encoding="UTF-8"?>
Netbeans does not consider the command line output. It considers the xml only. Did you add the missing XML element? If your xml element is equal to <testsuite name="Webapp_Model_PhpUnitTest::testMyThing" tests="0" assertions="0" failures="0" errors="0" time="0.000000"/>
then netbeans will recognize it as a skipped test suite.
Okay, I fixed this issue here: http://github.com/whatthejeff/phpunit/tree/topic_13. I made the following changes:
<testsuite>
element in the JUNIT format.<testsuite>
element in the JUNIT format.I still think that the JUNIT result printer could be more consistent. Judging from the netbeans source code, netbeans generates the "skipped" message because it knows that an empty test suite normally triggers a warning but it has no access to the actual warning in the JUNIT results. It seems like it would make more sense (and would be more consistent with the actual JUNIT DTD) if warnings were reported inside of the <tesetsuite>
elements. For example:
<testsuite name="ATest" tests="0" assertions="0" failures="1" errors="0" time="0.000000">
<failure type="PHPUnit_Framework_Warning">ATest::testA
No tests found in class "ATest".
</failure>
</testsuite>
This would make the JUNIT results printer more consistent with the other result printers and it would allow applications like neatbeans the possibility of handling warnings more gracefully.
Would be nice if sebastian will merge this soon.
I hope to see this soon in 3.5.0RCx
Hi whatthejeff,
i can not get the result by using your code. I did a checkout on http://github.com/whatthejeff/phpunit.git and copy the "PHPUnit" folder to the PEAR folder of my XAMPP. But i did not get the <testsuite>
element in the result xml (when i used an invalid @dataProvider method name when using the --log-junit). Issue not fixed?
Make sure you checkout the topic_13 branch as this bug is fixed in that branch and not the master branch. Something along the lines of:
git checkout topic_13
Sorry for my incompetence (this is my first time in using git). When i use http://github.com/whatthejeff/phpunit/tree/topic_13 as URL to clone repo via TortoiseGit (Windows) i get the error: fatal: http://github.com/whatthejeff/phpunit/tree/topic_13/info/refs not found: did you run git update-server-info on the server?
Just use the download source button at the top of this page: http://github.com/whatthejeff/phpunit/tree/topic_13.
Closed by 5a83f4a6c2d9416ad576701047659f9ae091ad97.
If a data provider function returns an emty array the results XML contains some XML elements about the skipped test (the test method that uses this data provider).
When defining a test method and using a @dataProvider annotation, but pointing to a non existing data provider function this should be create the same XML about the skipped test.
Because of the missing XML about the skipped test (second example above) i can not notice the skipped test in my IDE (netbeans).