All Projects โ†’ hollodotme โ†’ phpunit-testdox-markdown

hollodotme / phpunit-testdox-markdown

Licence: MIT license
A PHPUnit test listener that creates a testdox markdown file with grouped dataset output

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to phpunit-testdox-markdown

phpunit-injector
Injects services from a PSR-11 dependency injection container to PHPUnit test cases
Stars: โœญ 62 (+416.67%)
Mutual labels:  phpunit-listener

Latest Stable Version Total Downloads

PHPUnit\TestListeners\TestDox

END OF LIFE

Please note: This project won't receive updates or fixes anymore and was marked as "abandoned" at packagist.org.

However, if you find this code useful in any way, feel free to fork, change and re-publish it. The MIT license applies.

Description

A PHPUnit test listener that creates a testdox markdown file with grouped dataset output

Requirements

  • PHP >= 7.1
  • PHPUnit >= 7.0

Installation

composer require --dev hollodotme/phpunit-testdox-markdown

Usage

If you are using PSR-4 autoloading, add the following to your phpunit.xml:

<phpunit ...>
    <listeners>
        <listener class="hollodotme\PHPUnit\TestListeners\TestDox\Markdown">
            <arguments>
                <string name="environment">Development</string>
                <string name="outputFile">build/logs/TestDox.md</string>
            </arguments>
        </listener>
    </listeners>
</phpunit>

If you're not using PSR-4 autoloading, also add the class' file path to the <listener> tag:

<phpunit ...>
    <listeners>
        <listener class="hollodotme\PHPUnit\TestListeners\TestDox\Markdown" 
                  file="/path/to/vendor/hollodotme/phpunit-testdox-markdown/src/Markdown.php">
            <arguments>
                <string name="environment">Development</string>
                <string name="outputFile">build/logs/TestDox.md</string>
            </arguments>
        </listener>
    </listeners>
</phpunit>

Available listener arguments

Name Type Required Meaning
environment string YES Is printed on top of the testdox report to identifiy on which build stage the report has been created.
outputFile string YES Relative path to the markdown testdox output file. Please note: the path must be relative to your current working directory, not to the location of the phpunit.xml.
baseNamespace string NO A part of your test namespace to shorten the output headlines. Example: Your test namespace is YourVendor\YourProject\Tests\Unit and you set baseNamespace to YourVendor\YourProject\Tests all headlines will be prefixed with Unit\ only.
testStatusMap array NO A key-value array of strings that let's you manipulate the icons for each test result status. See example below.

Example with all available arguments

<phpunit ...>
    <listeners>
        <listener class="hollodotme\PHPUnit\TestListeners\TestDox\Markdown">
            <arguments>
                <string name="environment">Development</string>
                <string name="outputFile">build/logs/TestDox.md</string>
                <string name="baseNamespace">YourVendor\YourProject\Tests</string>
                <array name="testStatusMap">
                    <element key="Passed">
                        <string>๐Ÿ’š</string>
                    </element>
                    <element key="Error">
                        <string>๐Ÿ’”</string>
                    </element>
                    <element key="Failure">
                        <string>๐Ÿ’”</string>
                    </element>
                    <element key="Warning">
                        <string>๐Ÿงก</string>
                    </element>
                    <element key="Risky">
                        <string>๐Ÿ’›</string>
                    </element>
                    <element key="Incomplete">
                        <string>๐Ÿ’™</string>
                    </element>
                    <element key="Skipped">
                        <string>๐Ÿ’œ</string>
                    </element>
                </array>
            </arguments>
        </listener>
    </listeners>
</phpunit>

Example output

๐Ÿ’š Passed | ๐Ÿ’” Error | ๐Ÿ’” Failure | ๐Ÿงก Warning | ๐Ÿ’› Risky | ๐Ÿ’™ Incomplete | ๐Ÿ’œ Skipped

# Test suite: Unit-Test-Suite

* Environment: `Testing`  
* Base namespace: `hollodotme\PHPUnit`  

## UnitTest

- [x] Can Have Single Test (๐Ÿ’š 1)
- [ ] Can Have Test With Data Sets (๐Ÿ’š 3, ๐Ÿ’› 3, ๐Ÿ’œ 3, ๐Ÿ’™ 3, ๐Ÿงก 3, ๐Ÿ’” 3)
  > 3: DataSet is risky.  
  > 4: DataSet is risky.  
  > 5: DataSet is risky.  
  > 6: DataSet was skipped.  
  > 7: DataSet was skipped.  
  > 8: DataSet was skipped.  
  > 9: DataSet is incomplete.  
  > 10: DataSet is incomplete.  
  > 11: DataSet is incomplete.  
  > 12: DataSet creates warning.  
  > 13: DataSet creates warning.  
  > 14: DataSet creates warning.  
  > 15: DataSet fails.  
  > 16: DataSet errors out.  
  > 17: DataSet errors out.  


---

Report created at 2018-05-21 22:23:12 (UTC)

๐Ÿ’š Passed | ๐Ÿ’” Error | ๐Ÿ’” Failure | ๐Ÿงก Warning | ๐Ÿ’› Risky | ๐Ÿ’™ Incomplete | ๐Ÿ’œ Skipped

Test suite: Unit-Test-Suite

  • Environment: Testing
  • Base namespace: hollodotme\PHPUnit

UnitTest

  • Can Have Single Test (๐Ÿ’š 1)
  • Can Have Test With Data Sets (๐Ÿ’š 3, ๐Ÿ’› 3, ๐Ÿ’œ 3, ๐Ÿ’™ 3, ๐Ÿงก 3, ๐Ÿ’” 3)

    3: DataSet is risky.
    4: DataSet is risky.
    5: DataSet is risky.
    6: DataSet was skipped.
    7: DataSet was skipped.
    8: DataSet was skipped.
    9: DataSet is incomplete.
    10: DataSet is incomplete.
    11: DataSet is incomplete.
    12: DataSet creates warning.
    13: DataSet creates warning.
    14: DataSet creates warning.
    15: DataSet fails.
    16: DataSet errors out.
    17: DataSet errors out.


Report created at 2018-05-21 22:23:12 (UTC)

Contributing

Contributions are welcome and will be fully credited. Please see the contribution guide for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].