Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No line of code was executed during tests. #1542

Closed
alexdodonov opened this issue Aug 2, 2021 · 4 comments · Fixed by #1550
Closed

No line of code was executed during tests. #1542

alexdodonov opened this issue Aug 2, 2021 · 4 comments · Fixed by #1550
Assignees
Labels
Milestone

Comments

@alexdodonov
Copy link

alexdodonov commented Aug 2, 2021

Question Answer
Infection version 0.21.5
Test Framework version PHPUnit 8.5.19
PHP version 7.4.4
Platform Windows
Github Repo https://github.com/alexdodonov/mezon-router

Hi! I am getting error "No line of code was executed during tests. This could be due to @covers annotations or your
PHPUnit filters not being set up correctly."

Here is infection config:

{
	"source": {
		"directories": [
			"./Mezon/Router"
		],
		"excludes": [
			"./Mezon/Router/Tests"
		]
	},
	"phpUnit": {
		"customPath": ".\/vendor\/phpunit\/phpunit\/phpunit"
	},
	"logs": {
		"text": ".\/tmp\/infection.txt"
	},
	"mutators": {
		"@default": true
	}
}

Here is PHPUnit config:

<?xml version="1.0" encoding="UTF-8"?>

<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.0/phpunit.xsd"
	backupGlobals="false" colors="true" bootstrap='./vendor/autoload.php'
	stopOnError="true" stopOnFailure="true">
	<php>
		<ini name="error_reporting" value="-1" />
	</php>

	<testsuites>
		<testsuite name="unit">
			<directory suffix="UnitTest.php">
				./Mezon/Router/Tests
			</directory>
		</testsuite>
	</testsuites>

	<filter>
		<whitelist>
			<directory>./Mezon/Router</directory>
			<exclude>
				<directory suffix="UnitTest.php">
					./Mezon/Router/Tests
				</directory>
				<directory>./vendor</directory>
				<file>autoload.php</file>
			</exclude>
		</whitelist>
	</filter>

	<logging>
		<log type="coverage-html"
			target="./tmp/coverage-phpunit.html"></log>
		<log type="coverage-text" target="php://stdout"
			showOnlySummary="true"></log>
	</logging>
</phpunit>

What do I do wrong?

@sanmai
Copy link
Member

sanmai commented Aug 3, 2021

Try running it with XDEBUG_MODE=coverage

@alexdodonov
Copy link
Author

It have not helped (

@maks-rafalko
Copy link
Member

Thank you very much for providing a repository with reproducible issue, this is how the bug report should look like!

I was able to reproduce it and the reason of this bug is quite interesting. Your phpunit.xml file contains \n\t around the relative paths, and when Infection tries to replace relative paths with absolute ones - it builds incorrect paths with \n\t inside, see

tabs-bug

#1550 fixes the issue.

While you are waiting for the new release, you can fix this issue just by updating your phpunit.xml like this:

tabs-bug-workaround

@maks-rafalko maks-rafalko added this to the 0.25.0 milestone Aug 9, 2021
@maks-rafalko maks-rafalko self-assigned this Aug 9, 2021
maks-rafalko added a commit that referenced this issue Aug 9, 2021
@alexdodonov
Copy link
Author

@maks-rafalko Thank you )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants