nikeee / nikeee/phpunit-tap

Outputs both TAP and default PHPUnit formatting

Open
#31 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

help wanted
Dominant language
PHP
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

Description:

When using the nikeee\PhpunitTap\TapExtension configured via the <extensions> block in phpunit.xml, both TAP formatted output and the default PHPUnit text output are shown. The expected behavior is to have only the TAP output printed to stdout.

Environment:

  • PHPUnit Version: 11.5.7
  • PHP Version: 8.4.3
  • phpunit-tap : v2.0.1

Steps to Reproduce:

  1. Create a project with the phpunit.xml configuration.
<?xml version="1.0" encoding="UTF-8"?>
<phpunit>
  <extensions>
    <bootstrap class="nikeee\PhpunitTap\TapExtension" />
  </extensions>
  <testsuites>
    <testsuite name="Example Test Suite">
      <directory suffix="Test.php">./tests</directory>
    </testsuite>
  </testsuites>
</phpunit>
  1. Add a test file (e.g., tests/FunctionsTest.php) containing both passing tests and a failing test. For example:

    <?php
    // tests/FunctionsTest.php
    
    use PHPUnit\Framework\TestCase;
    
    // Include the procedural functions
    require_once __DIR__ . '/../src/functions.php';
    
    final class FunctionsTest extends TestCase
    {
        public function testAdd(): void
        {
            $this->assertEquals(5, add(2, 3));
        }
    
        public function testAddWithNegativeNumbers(): void
        {
            $this->assertEquals(-2, add(-1, -1));
        }
    
        public function testAddWillFail(): void
        {
            // Intentionally failing test: Expect 2 but add(1, 5) returns 6
            $this->assertEquals(2, add(1, 5), '1 + 5 should equal 6, but we fail on purpose');
        }
    }
    
  2. Run PHPUnit from the command line:

    ./vendor/bin/phpunit
    

Actual Output:

./vendor/bin/phpunit 
PHPUnit 11.5.7 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.3
Configuration: /path/to/projects/phpunit-tap-sandbox/phpunit.xml

..F                                                                 3 / 3 (100%)TAP version 13
1..3
ok - FunctionsTest::testAdd # time=4.389ms
ok - FunctionsTest::testAddWithNegativeNumbers # time=0.038ms
not ok - FunctionsTest::testAddWillFail # time=37.694ms
  ---
  message: 'Comparison Failure'
  severity: fail
  thrown: false
  actual: '6'
  expected: '2'
  ...

Time: 00:00.099, Memory: 8.00 MB

There was 1 failure:

1) FunctionsTest::testAddWillFail
1 + 5 should equal 6, but we fail on purpose here.
Failed asserting that 6 matches expected 2.

/path/to/projects/phpunit-tap-sandbox/tests/FunctionsTest.php:31

FAILURES!
Tests: 3, Assertions: 3, Failures: 1.

Expected Output:

Only the TAP formatted output should be printed (for example):

TAP version 13
1..3
ok - FunctionsTest::testAdd # time=...ms
ok - FunctionsTest::testAddWithNegativeNumbers # time=...ms
not ok - FunctionsTest::testAddWillFail # time=...ms
  ---
  ...

There should be no additional default PHPUnit summary output (header, progress dots, and final summary).

Please advise if this is an intended behavior, a configuration issue, or a bug. Any assistance or a workaround would be greatly appreciated.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue using the phpunit.xml configuration, tests/FunctionsTest.php, and ./vendor/bin/phpunit. Start by reading the nikeee\PhpunitTap\TapExtension entry point and compare the captured stdout with the expected TAP-only output. Done means the extension emits TAP output without the default PHPUnit header, progress dots, or final summary.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.