How to disable stack trace on PHPUnit assert failure?


If I run PHPUnit test via PhpStorm, It gives me this output:

PHPUnit_Framework_ExpectationFailedException : Failed asserting that two strings are equal.
Expected :Lorem ipsum [[$n$-ojo$:$n$-ojo$]] dolor sit amet.
Actual   :Lorem ipsum $n$-ojo$ dolor sit amet.
<Click to see difference>

#0 /usr/share/php/PHPUnit/Framework/Assert.php(2100): PHPUnit_Framework_Constraint_IsEqual->evaluate('Lorem ipsum $n$...', '')
#1 /usr/share/php/PHPUnit/Framework/Assert.php(441): PHPUnit_Framework_Assert::assertThat('Lorem ipsum $n$...', Object(PHPUnit_Framework_Constraint_IsEqual), '')
#2 /home/infro/dev/foo/public_html/src/RAZ/CoreBundle/Tests/Services/TheoryDefinitionServiceTest.php(38): PHPUnit_Framework_Assert::assertEquals('Lorem ipsum [[$...', 'Lorem ipsum $n$...')
#3 [internal function]: RAZ\CoreBundle\Tests\Services\TheoryDefinitionServiceTest->testReplaceDefinitionsForQuestions('Lorem ipsum $n$...', Array, 'Lorem ipsum [[$...')
#4 /usr/share/php/PHPUnit/Framework/TestCase.php(942): ReflectionMethod->invokeArgs(Object(RAZ\CoreBundle\Tests\Services\TheoryDefinitionServiceTest), Array)
#5 /usr/share/php/PHPUnit/Framework/TestCase.php(804): PHPUnit_Framework_TestCase->runTest()
#6 /usr/share/php/PHPUnit/Framework/TestResult.php(649): PHPUnit_Framework_TestCase->runBare()
#7 /usr/share/php/PHPUnit/Framework/TestCase.php(751): PHPUnit_Framework_TestResult->run(Object(RAZ\CoreBundle\Tests\Services\TheoryDefinitionServiceTest))
#8 /usr/share/php/PHPUnit/Framework/TestSuite.php(772): PHPUnit_Framework_TestCase->run(Object(PHPUnit_Framework_TestResult))
#9 /usr/share/php/PHPUnit/Framework/TestSuite.php(745): PHPUnit_Framework_TestSuite->runTest(Object(RAZ\CoreBundle\Tests\Services\TheoryDefinitionServiceTest), Object(PHPUnit_Framework_TestResult))
#10 /usr/share/php/PHPUnit/Framework/TestSuite.php(705): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult), false, Array, Array, false)
#11 /usr/share/php/PHPUnit/TextUI/TestRunner.php(325): PHPUnit_Framework_TestSuite->run(Object(PHPUnit_Framework_TestResult), false, Array, Array, false)
#12 /usr/share/php/PHPUnit/TextUI/Command.php(192): PHPUnit_TextUI_TestRunner->doRun(Object(PHPUnit_Framework_TestSuite), Array)
#13 /tmp/ide-phpunit.php(268): PHPUnit_TextUI_Command->run(Array, true)
#14 /tmp/ide-phpunit.php(506): IDE_Base_PHPUnit_TextUI_Command::main()
#15 {main}

I would want to only first 4 lines of information. I tried running phpunit outside from PhpStorm, it gives me different output, so it seems that the output is generated in PhpStorm.
Also this question confirms this (see question update):
I am using Symfony 2.4 for a framework if it matters. PhpStorm 7.1.1, but I think it was the same in version 6.

Was not able to find any configuration or workaround for that.

Any ideas?

Comment actions Permalink

You can not disable it, because though tests run through our script (/tmp/ide-phpunit.php), but the stack trace itself is generated by PhpUnit.

I'd recommend you to create a new issue on our tracker (e.g."Allow to disable stack trace on PHPUnit assert failure"): .

See if you are not familiar with YouTrack.

Comment actions Permalink

Thank you. Missed it.

Comment actions Permalink

Yes, this seems to be a bug. Thanks for finding it.
Will wait for fix and for now I just keep using phpunit directly via terminal.

Comment actions Permalink

This is is a much more serious issue, which almost makes the phpunit integration useless. The "stack trace" which is actually a result from the exception not handled correctly in IntelliJ causes the following issues:
- the test result is shown as "error" (with exclamation mark), not as "failed" (negative sign)
- when you click on the failed test, you get moved to the Assert class and not the failing test.


Please sign in to leave a comment.