I have some issues with code coverage reports in PHPunit and the zend framework. Whenever I run a phpunit test the code coverage fails returning the following message:
PHPUnit 3.4.15 by Sebastian Bergmann.
I.......III.I................................IIIIIIIIIIIIIII 60 / 93
IIII....I....I..II..II.....IIIIII
Time: 4 seconds, Memory: 22.25Mb
OK, but incomplete or skipped tests!
Tests: 93, Assertions: 174, Incomplete: 36.
Generating code coverage report, this may take a moment.PHP Fatal error: Cannot redeclare class Klunde_Auth in /Users/kristianlunde/workspaces/private/klunde/Library/Klunde/Auth.php on line 9
Fatal error: Cannot redeclare class Klunde_Auth in /Users/kristianlunde/workspaces/private/klunde/Library/Klunde/Auth.php on line 9
My phpunit.xml file looks like this:
<phpunit bootstrap="./application/bootstrap.php" colors="true">
<testsuite name="Klunde">
<directory>./application/</directory>
<directory>./Library/Klunde</directory>
</testsuite>
<filter>
<whitelist>
<directory suffix=".php">../application</directory>
<directory suffix=".php">../Library/Klunde</directory>
<exclude>
<directory suffix=".phtml">../application/</directory>
<file>../application/Bootstrap.php</file>
<file>../application/controllers/ErrorController.php</file>
</exclude>
</whitelist>
</filter>
<logging>
<log type="coverage-html" target="./log/report" charset="UTF-8" yui="true"
highlight="true" lowUpperBound="50" highLowerBound="80" />
<log type="testdox-html" target="./log/testdox.html" />
</logging>
</phpunit>
I did a
var_dump(get_included_files());
at the top of the Auth file and it did try to include the file more than once before it failed.
I have also tried to remove the Klunde_Auth.php file just to see if it was a one file issue, but then the error is triggered on the next file in the Library/Klunde directory.
I am running OSX Snow Leopard, with PHP 5.3.1, XDebug 2.1.0beta3 and PHPUnit 3.4.15
All help and assistance will be highly appreciated.
Thanks.
add a debug_print_backtrace() call to the top of your Klunde_Auth.php, before the class declaration itself starts.
Then run the testsuite again, now you will see the whole backtrace each time the file is included, this should help you to figure out what/from where it is being included twice.
Related
How to send the XML report to SonarQube? I mean, while the TEST-report.xml file contains any failures, the import operation fails. I got an error:
Running SonarQube using SonarQube Runner.17:18:18.452 ERROR: Error during SonarScanner execution
java.lang.NullPointerException
at java.text.DecimalFormat.parse(DecimalFormat.java:2030)
at java.text.NumberFormat.parse(NumberFormat.java:383)
...
The TEST-report.xml file (JUnit) contains something like:
<?xml version='1.0' encoding='UTF-8'?>
<testsuites name='X UITests.xctest' tests='12' failures='3'>
<testsuite name='X.MoreViewTests' tests='1' failures='1'>
<testcase classname='X.MoreViewTests' name='testSucceed_allAction'>
<failure message='XCTAssertTrue failed'>X UITests/Cases/Bottom Navigation/MoreViewTests.swift:212</failure>
</testcase>
</testsuite>
<testsuite name='X.OrderViewTests' tests='1' failures='0'>
<testcase classname='X.OrderViewTests' name='testSucceed_allAction' time='68.570'/>
</testsuite>
</testsuites>
But when I removed the failure lines, becomes:
<?xml version='1.0' encoding='UTF-8'?>
<testsuites name='X UITests.xctest' tests='12' failures='3'>
<testsuite name='X.OrderViewTests' tests='1' failures='0'>
<testcase classname='X.OrderViewTests' name='testSucceed_allAction' time='68.570'/>
</testsuite>
</testsuites>
It works. Any idea? Thanks.
Your XML report is invalid (doesn't meet the Surefire XML format requirements).
testsuite required parameters:
name - Full class name of the test for non-aggregated testsuite documents. Class name without the package for aggregated testsuites documents
tests - The total number of tests in the suite
failures - The total number of tests in the suite that failed. A failure is a test which the code has explicitly failed by using the mechanisms for that purpose. e.g., via an assertEquals
errors - The total number of tests in the suite that errored. An errored test is one that had an unanticipated problem. e.g., an unchecked throwable; or a problem with the implementation of the test
skipped - The total number of ignored or skipped tests in the suite
The exception starts with DecimalFormat.parse
java.lang.NullPointerException
at java.text.DecimalFormat.parse(DecimalFormat.java:2030)
at java.text.NumberFormat.parse(NumberFormat.java:383)
which means that the XML report parser couldn't parse a number. You have two missing parameters: errors and skipped. I don't know how you generate these reports (which JUnit version etc.), but probably the used tool is outdated or miss-configured.
I experience a problem using a batch file to call Regasm on framework 4 on a network drive.
It works correctly when the dll is on a local drive.
The message is Could not load file or assembly filename.dll or one of its dependencies. Operation is not supported.
The problem is discussed
here ad "Darrens Developer Diary"
however editing the config as described does not help
I also tried the advice
here
which differs in the line
<loadFromRemoteSources="true"/>
with this I received a different error
"The system cannot execute the specified program"
The DLL used to use Framework 2, but I unregistered it using Framework 2 Regasm.
Here is the regasm.exe.config
<?xml version ="1.0"?>
<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime safemode="true" imageVersion="v4.0.30319" version="v4.0.30319"/>
<supportedRuntime version="v4.0" sku="client" />
</startup>
<runtime>
<loadfromremotesources enabled="true"> </loadfromremotesources>
</runtime>
</configuration>
Here is the command in my batch file
Z:
cd foldername
c:\WINDOWS\Microsoft.Net\Framework\v4.0.30319/regasm /verbose /codebase /tlb: .\SBD.CommBridge.tlb .\SBD.ComBridge.dll
The correct line in regasm.exe.config is
<loadFromRemoteSources enabled="true"/>
the case matters
I'm trying to use an oni recording in my application using OpenNI. Here is my xml file:
<OpenNI>
<Licenses>
<!-- Add application-specific licenses here
<License vendor="vendor" key="key"/>
-->
</Licenses>
<Log writeToConsole="false" writeToFile="false">
<!-- 0 - Verbose, 1 - Info, 2 - Warning, 3 - Error (default) -->
<LogLevel value="3"/>
<Masks>
<Mask name="ALL" on="true"/>
</Masks>
<Dumps>
</Dumps>
</Log>
<ProductionNodes>
<Recording file="Recording.oni" />
<!-- Set global mirror -->
<GlobalMirror on="true"/>
</ProductionNodes>
</OpenNI>
Everything looks ok, but when I try to run my program, I get:
Open failed: Function was not implemented!
What could be the problem?
The problem were the two following lines:
<!-- Set global mirror -->
<GlobalMirror on="true"/>
After removing them, my program works fine.
My unit tests are being executed and reports written, however the coverage reports are empty. This is the Nant task I'm using:
<target name="unitTests">
<foreach item="File" property="filename">
<in>
<items>
<include name="**\UnitTestBinaries\*.UnitTests.*.dll"></include>
</items>
</in>
<do>
<exec program="${ncover-console}"
workingdir="${path::get-directory-name(filename)}"
commandline=""${nunit-console}" ${filename} /xml:${project::get-base-directory()}\_nunit_${path::get-file-name-without-extension(filename)}.xml /nologo //x ${project::get-base-directory()}\_ncover_${path::get-file-name-without-extension(filename)}.xml"
failonerror="true"
verbose="true"/>
</do>
</foreach>
</target>
Any ideas why I'm not getting coverage data? Is there any easier way to achieve this step?
Thanks for any help.
Edit:
This is an example output file:
<!-- saved from NCover 3.0 Export url='http://www.ncover.com/' -->
<coverage profilerVersion="3.3.0.6070" driverVersion="3.3.0" exportversion="3" viewdisplayname="" startTime="2011-10-31T23:27:33.3688015Z" measureTime="2011-10-31T23:27:36.1420615Z" projectName="" buildid="d3a76074-bb16-4677-8273-91c7b6552066" coveragenodeid="0" failed="false" satisfactorybranchthreshold="95" satisfactorycoveragethreshold="95" satisfactorycyclomaticcomplexitythreshold="20" satisfactoryfunctionthreshold="80" satisfactoryunvisitedsequencepoints="10" uiviewtype="TreeView" viewguid="C:\_documents\CI\_ncover_XTFL.UnitTests.Core.xml" viewfilterstyle="None" viewreportstyle="SequencePointCoveragePercentage" viewsortstyle="Name">
<rebasedpaths />
<filters />
<documents>
<doc id="0" excluded="false" url="None" cs="" csa="00000000-0000-0000-0000-000000000000" om="0" nid="0" />
</documents>
</coverage>
Edit II:
This is a sample of the buildlog output (edited for security):
<task name="ncover">
<message level="Info"><![CDATA[Command: C:\Program Files\NUnit 2.5.10\bin\net-2.0\nunit-console.exe]]></message>
<message level="Info"><![CDATA[Command Args: C:\_documents\CI\Working\UnitTestBinaries\XTFL.UnitTests.Workflow.dll /xml:C:\_documents\CI\_nunit_XTFL.UnitTests.Workflow.xml /nologo /noshadow]]></message>
<message level="Info"><![CDATA[Working Directory:]]></message>
<message level="Info"><![CDATA[Assemblies: (All Loaded Assemblies)]]></message>
<message level="Info"><![CDATA[******************* Program Output *******************]]></message>
<message level="Info"><![CDATA[ProcessModel: Default DomainUsage: Single]]></message>
<message level="Info"><![CDATA[Execution Runtime: Default]]></message>
<message level="Info"><![CDATA[..........]]></message>
<message level="Info"><![CDATA[Tests run: 10, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.9677115 seconds]]></message>
<message level="Info"><![CDATA[Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0]]></message>
<message level="Info"><![CDATA[***************** End Program Output *****************]]></message>
<message level="Info"><![CDATA[Execution Time: 2.8983 s]]></message>
<message level="Info"><![CDATA[Coverage Xml: C:\_documents\CI\_ncover_XTFL.UnitTests.Workflow.xml]]></message>
<duration>3278.1105000000002</duration>
</task>
If your NCover license allows, recommend upgrading to 3.4.18.
Based on the messages alone, it looks like profiling never begins on your NUnit process.
I can't see the exact command line syntax from the NAnt task, but NCover has to start NUnit in order to profile the unit test DLL.
If NCover is starting NUnit successfully, you should see a message after the "Program Output" that says, "Process 'nunit-agent' [PID 3116] has begun profiling" before the NUnit test results, and another message after the results that "Process 'nunit-agent' [PID 3116] has finished profiling".
I remember having a similar problem. Are you placing the related .pdb files besides the assembly files? That solved it for me.
That's a good tip re: the PDB files, but even without them, you should get Branch coverage, though you won't get any Symbols.
In IIS 6, using Perl, I was able to send a stream of output to the client rather than buffering the entire thing and dumping it out at all once. This allowed such things as progress bars and such to be used.
How can I accomplish the same thing in IIS 7?
Under IIS 7, once you have created the Perl Script script mapping, you can add an attribute that will fix this.
You modify the %windir%\system32\inetsrv\config\applicationHost.control file and find the script mapping by name (in my case, Perl-Script). Then add the responseBufferLimit attribute into the XML, for example:
<add name="Perl-Script" path="*.pl" blah blah blah responseBufferLimit="0" />
This causes IIS to run as it did in IIS 6, with buffering off.
You can customize the web application's web.config to set responseBufferLimit="0" instead of changing global settings. Example web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="Perl CGI for .pl (custom)" path="*.pl" verb="GET,HEAD,POST" modules="CgiModule" scriptProcessor="C:\Perl64\bin\perl.exe "%s" %s" resourceType="File" requireAccess="Script" responseBufferLimit="0" />
</handlers>
</system.webServer>
<system.web>
<identity impersonate="false" />
</system.web>
</configuration>
Place this file in the web root directory. It will override server settings for *.pl.
The ONLY thing that worked for my in IIS 7.5 (Windows 7) was the following command, run from CMD:
appcmd.exe set config /section:handlers "/[name='PHP_via_FastCGI'].ResponseBufferLimit:0"
NOTE: You must replace PHP_via_FastCGI with the name of your PHP handler in "Handler Mappings".