public function parseBehatOutput()
    {
        $output = $this->phpci->getLastOutput();

        $parts = explode('---', $output);

        if (count($parts) <= 1) {
            return array(0, array());
        }

        $lines = explode(PHP_EOL, $parts[1]);

        $storeFailures = false;
        $data = array();

        foreach ($lines as $line) {
            $line = trim($line);
            if ($line == 'Failed scenarios:') {
                $storeFailures = true;
                continue;
            }

            if (strpos($line, ':') === false) {
                $storeFailures = false;
            }

            if ($storeFailures) {
                $lineParts = explode(':', $line);
                $data[] = array(
                    'file' => $lineParts[0],
                    'line' => $lineParts[1]
                );

                $this->build->reportError(
                    $this->phpci,
                    'behat',
                    'Behat scenario failed.',
                    BuildError::SEVERITY_HIGH,
                    $lineParts[0],
                    $lineParts[1]
                );
            }
        }

        $errorCount = count($data);

        return array($errorCount, $data);
    }