Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: SonarQube z UnitTests
Forum PHP.pl > Inne > Hydepark
nospor
hejka, do analizy projektu uzywam SonarQube. W projekcie mam unittests i generuje raporty
W konfiguracji sonarqube w projekcie ustawiam

Kod
sonar.php.tests.reportPath=/.../logfile.xml
sonar.php.coverage.reportPaths=/.../coverage.xml

O ile code coverage jest ladnie lykane przez SonarQube o tyle testy juz nie. CIagle dostaje bledy w stylu:
Kod
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #0 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #1 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #2 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #3 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #4 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #5 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #6 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\Reader\GridTest.testGrid with data set #7 in Tests\Unit\DataService\Reader\GridTest::testGrid
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testNames with data set #0 in Tests\Unit\DataService\SurveyTest::testNames
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testNames with data set #1 in Tests\Unit\DataService\SurveyTest::testNames
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testNames with data set #2 in Tests\Unit\DataService\SurveyTest::testNames
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testNames with data set #3 in Tests\Unit\DataService\SurveyTest::testNames
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testTypes with data set #0 in Tests\Unit\DataService\SurveyTest::testTypes
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testTypes with data set #1 in Tests\Unit\DataService\SurveyTest::testTypes
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testTypes with data set #2 in Tests\Unit\DataService\SurveyTest::testTypes
WARN: Test cases must always be descendants of a file-based suite, skipping : Tests\Unit\DataService\SurveyTest.testTypes with data set #3 in Tests\Unit\DataService\SurveyTest::testTypes


Plik logfile.xml jest wygenerowany przez phpunit z takie konfiguracji
<log type="junit" target="/.../logfile.xml" logIncompleteSkipped="false"/>
<log type="coverage-clover" target="/.../coverage.xml"/>


A tak wyglada pare pierwszych linijek logfile.xml:
Kod
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="" tests="104" assertions="122" errors="0" failures="0" skipped="0" time="1.011804">
    <testsuite name="functional" tests="44" assertions="50" errors="0" failures="0" skipped="0" time="0.780856">
      <testsuite name="Tests\Functional\DataService\FileIO\AnswersFileIOTest" file="/var/www/test/data-service/tests/Functional/DataService/FileIO/AnswersFileIOTest.php" tests="2" assertions="4" errors="0" failures="0" skipped="0" time="0.006286">
        <testcase name="testLoad" class="Tests\Functional\DataService\FileIO\AnswersFileIOTest" classname="Tests.Functional.DataService.FileIO.AnswersFileIOTest" file="/var/www/test/data-service/tests/Functional/DataService/FileIO/AnswersFileIOTest.php" line="10" assertions="1" time="0.004075"/>
        <testcase name="testWrite" class="Tests\Functional\DataService\FileIO\AnswersFileIOTest" classname="Tests.Functional.DataService.FileIO.AnswersFileIOTest" file="/var/www/test/data-service/tests/Functional/DataService/FileIO/AnswersFileIOTest.php" line="36" assertions="3" time="0.002211"/>
      </testsuite>
      <testsuite name="Tests\Functional\DataService\FileIO\QuestionsFileIOTest" file="/var/www/test/data-service/tests/Functional/DataService/FileIO/QuestionsFileIOTest.php" tests="2" assertions="4" errors="0" failures="0" skipped="0" time="0.004041">
        <testcase name="testLoad" class="Tests\Functional\DataService\FileIO\QuestionsFileIOTest" classname="Tests.Functional.DataService.FileIO.QuestionsFileIOTest" file="/var/www/test/data-service/tests/Functional/DataService/FileIO/QuestionsFileIOTest.php" line="10" assertions="1" time="0.002783"/>
        <testcase name="testWrite" class="Tests\Functional\DataService\FileIO\QuestionsFileIOTest" classname="Tests.Functional.DataService.FileIO.QuestionsFileIOTest" file="/var/www/test/data-service/tests/Functional/DataService/FileIO/QuestionsFileIOTest.php" line="26" assertions="3" time="0.001258"/>
      </testsuite>
.....

Googlalem ale nie bylem wstanie nic znalezc sad.gif



edit:
Pozwole sobie odswiezyc temat po paru miesiacach bo moze ktos cos juz mial podobnego?
com
http://kwebble.com/blog/2015-05-25_23:22:12 tak próbowałeś?
nospor
Jedyna roznica jaka widze to ze u niego tests jest w src a umnie to sa katalogi rownolegle
Mi generalnie coverage pokazuje w sonarqube ale sa te ostrzezenia co pokazalem oraz coverage jest zanizony wzgledem coverage generowanym przez phpunit.
com
bardziej miałem na myśli te linie
Kod
sonar.tests=src/test/php

Bo tego nie pokazałeś, a to jest ważne tongue.gif
Pamiętam, że też miałem z tym problem, żeby testy ogarniał i to była zabawa. Ale już nie pamiętam czy w końcu je złapał lub czy to olałem.
nospor
Z ta linia czy bez, wynik ten sam sad.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.