Test coverage on PHPUnit 6.5.5 and PHP 7.2

前端 未结 3 1802
名媛妹妹
名媛妹妹 2021-01-27 02:23

the problem is that lines with the switch case are not covered, the switch cases themselves are being executed.

Tested on windows

3条回答
  •  无人及你
    2021-01-27 02:58

    Best alternative: pcov

    This is more faster than XDebug. More info https://github.com/krakjoe/pcov.

    Another alternative: XDebug

    XDebuyg will always be the best option as it is the one with the most community and time. The bad thing is that it is usually very slow compared to other roads. Dont forget update to last version ;).

    Temporary solution for phpdbg

    Option 1. Use CONSTANTS instead of magic strings. For example:

    class SectionTypes
    {
        public const APP = 'app';
        public const SHARE = 'share';
    }
    
    /* ... */
    
    case ($type) {
        case SectionTypes::APP:
            /* do something */
            break;
    }
    

    Option 2. Use concatenations. For example:

    case ($type) {
        case 'app'.'':
            /* do something */
            break;
    }
    

    Off course, the last option is ugly and not very recommended, but it can help you quickly.

提交回复
热议问题